[PATCH] git-merge-one-file-script cleanups from Cogito
[git.git] / git-commit-script
1 #!/bin/sh
2 : ${GIT_DIR=.git}
3 PARENTS="HEAD"
4 if [ -f $GIT_DIR/MERGE_HEAD ]; then
5         echo "#"
6         echo "# It looks like your may be committing a MERGE."
7         echo "# If this is not correct, please remove the file"
8         echo "# $GIT_DIR/MERGE_HEAD"
9         echo "# and try again"
10         echo "#"
11         PARENTS="HEAD -p MERGE_HEAD"
12 fi > .editmsg
13 git-status-script >> .editmsg
14 if [ "$?" != "0" ]
15 then
16         cat .editmsg
17         exit 1
18 fi
19 ${VISUAL:-${EDITOR:-vi}} .editmsg
20 grep -v '^#' < .editmsg | git-stripspace > .cmitmsg
21 [ -s .cmitmsg ] || exit 1
22 tree=$(git-write-tree) || exit 1
23 commit=$(cat .cmitmsg | git-commit-tree $tree -p $PARENTS) || exit 1
24 echo $commit > $GIT_DIR/HEAD
25 rm -f -- $GIT_DIR/MERGE_HEAD