3 # Copyright (c) 2005 Linus Torvalds
6 . git-sh-setup-script || die "Not a git archive"
9 die 'git commit [-m existing-commit] [<path>...]'
12 while case "$#" in 0) break ;; esac
18 *) use_commit=`git-rev-parse "$1"` ||
28 git-update-cache -q --refresh -- "$@" || exit 1
30 if [ ! -r "$GIT_DIR/HEAD" ]; then
31 if [ -z "$(git-ls-files)" ]; then
32 echo Nothing to commit 1>&2
37 echo "# Initial commit"
39 git-ls-files | sed 's/^/# New file: /'
44 if [ -f "$GIT_DIR/MERGE_HEAD" ]; then
46 echo "# It looks like your may be committing a MERGE."
47 echo "# If this is not correct, please remove the file"
48 echo "# $GIT_DIR/MERGE_HEAD"
49 echo "# and try again"
51 PARENTS="-p HEAD -p MERGE_HEAD"
52 elif test "$use_commit" != ""
57 s/^author \([^<]*\) <[^>]*> .*$/\1/
59 s/.*/GIT_AUTHOR_NAME='\''&'\''/p
62 s/^author [^<]* <\([^>]*\)> .*$/\1/
64 s/.*/GIT_AUTHOR_EMAIL='\''&'\''/p
67 s/^author [^<]* <[^>]*> \(.*\)$/\1/
69 s/.*/GIT_AUTHOR_DATE='\''&'\''/p
74 set_author_env=`git-cat-file commit "$use_commit" |
75 sed -ne "$pick_author_script"`
76 eval "$set_author_env"
77 export GIT_AUTHOR_NAME
78 export GIT_AUTHOR_EMAIL
79 export GIT_AUTHOR_DATE
80 git-cat-file commit "$use_commit" |
83 git-status-script >>.editmsg
93 ${VISUAL:-${EDITOR:-vi}} .editmsg
96 grep -v '^#' < .editmsg | git-stripspace > .cmitmsg
98 tree=$(git-write-tree) &&
99 commit=$(cat .cmitmsg | git-commit-tree $tree $PARENTS) &&
100 echo $commit > "$GIT_DIR/HEAD" &&
101 rm -f -- "$GIT_DIR/MERGE_HEAD"
103 rm -f .cmitmsg .editmsg