X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=git-commit.sh;h=591fcdceb1a3d47ce311bda0b3a81b62e99f47fc;hb=d1c5f2a42d7b5c0e3d3862212dea1f09809c4963;hp=d8bfc3c254929d3fb7a8aa702b4f4a86edefe8f0;hpb=91063bbc6c4187184e94ebc4ab2b807e6d53cd0a;p=git.git diff --git a/git-commit.sh b/git-commit.sh index d8bfc3c2..591fcdce 100755 --- a/git-commit.sh +++ b/git-commit.sh @@ -94,13 +94,13 @@ esac case "$all,$#" in t,*) git-diff-files --name-only -z | - xargs -0 git-update-index -q --remove -- + git-update-index --remove -z --stdin ;; ,0) ;; *) git-diff-files --name-only -z "$@" | - xargs -0 git-update-index -q --remove -- + git-update-index --remove -z --stdin ;; esac || exit 1 git-update-index -q --refresh || exit 1 @@ -133,14 +133,20 @@ fi | git-stripspace >.editmsg case "$signoff" in t) - git-var GIT_COMMITTER_IDENT | sed -e ' - s/>.*/>/ - s/^/Signed-off-by: / - ' >>.editmsg + { + echo + git-var GIT_COMMITTER_IDENT | sed -e ' + s/>.*/>/ + s/^/Signed-off-by: / + ' + } >>.editmsg ;; esac if [ -f "$GIT_DIR/MERGE_HEAD" ]; then + + test -f "$GIT_DIR/MERGE_MSG" && cat "$GIT_DIR/MERGE_MSG" + echo "#" echo "# It looks like your may be committing a MERGE." echo "# If this is not correct, please remove the file" @@ -150,13 +156,8 @@ if [ -f "$GIT_DIR/MERGE_HEAD" ]; then fi >>.editmsg PARENTS="-p HEAD" -if [ ! -r "$GIT_DIR/HEAD" ]; then - if [ -z "$(git-ls-files)" ]; then - echo Nothing to commit 1>&2 - exit 1 - fi - PARENTS="" -else +if GIT_DIR="$GIT_DIR" git-rev-parse --verify HEAD >/dev/null 2>&1 +then if [ -f "$GIT_DIR/MERGE_HEAD" ]; then PARENTS="-p HEAD "`sed -e 's/^/-p /' "$GIT_DIR/MERGE_HEAD"` fi @@ -189,9 +190,15 @@ else export GIT_AUTHOR_EMAIL export GIT_AUTHOR_DATE fi +else + if [ -z "$(git-ls-files)" ]; then + echo Nothing to commit 1>&2 + exit 1 + fi + PARENTS="" fi git-status >>.editmsg -if [ "$?" != "0" -a ! -f $GIT_DIR/MERGE_HEAD ] +if [ "$?" != "0" -a ! -f "$GIT_DIR/MERGE_HEAD" ] then rm -f .editmsg git-status @@ -217,7 +224,7 @@ if test -s .cmitchk then tree=$(git-write-tree) && commit=$(cat .cmitmsg | git-commit-tree $tree $PARENTS) && - echo $commit > "$GIT_DIR/HEAD" && + git-update-ref HEAD $commit $current && rm -f -- "$GIT_DIR/MERGE_HEAD" else echo >&2 "* no commit message? aborting commit."