Merge branch 'sp/checkout' into next
[git.git] / git-commit.sh
index c9c22ab..330a434 100755 (executable)
@@ -595,19 +595,21 @@ then
                PARENTS=$(git-cat-file commit HEAD |
                        sed -n -e '/^$/q' -e 's/^parent /-p /p')
        fi
+       current=$(git-rev-parse --verify HEAD)
 else
        if [ -z "$(git-ls-files)" ]; then
                echo >&2 Nothing to commit
                exit 1
        fi
        PARENTS=""
+       current=
 fi
 
 {
        test -z "$only_include_assumed" || echo "$only_include_assumed"
        run_status
 } >>"$GIT_DIR"/COMMIT_EDITMSG
-if [ "$?" != "0" -a ! -f "$GIT_DIR/MERGE_HEAD" ]
+if [ "$?" != "0" -a ! -f "$GIT_DIR/MERGE_HEAD" -a -z "$amend" ]
 then
        rm -f "$GIT_DIR/COMMIT_EDITMSG"
        run_status