1#!/bin/sh
2: ${GIT_DIR=.git}
3PARENTS="HEAD"
4if [ -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"
12fi > .editmsg
13git-status-script >> .editmsg
14if [ "$?" != "0" ]
15then
16 cat .editmsg
17 exit 1
18fi
19${VISUAL:-${EDITOR:-vi}} .editmsg
20grep -v '^#' < .editmsg | git-stripspace > .cmitmsg
21[ -s .cmitmsg ] || exit 1
22tree=$(git-write-tree) || exit 1
23commit=$(cat .cmitmsg | git-commit-tree $tree -p $PARENTS) || exit 1
24echo $commit > $GIT_DIR/HEAD
25rm -f -- $GIT_DIR/MERGE_HEAD