Skip to content

Commit 4fb5fd5

Browse files
ldv-altgitster
authored andcommitted
git-commit: Disallow amend if it is going to produce an empty non-merge commit
Right now one can amend the last non-merge commit using a dirty index and in the process maybe cause the last commit to have the same tree as its parent. In such a case one would want to discard the last commit instead of amending it. This reverts commit 8588452. Signed-off-by: Dmitry V. Levin <ldv@altlinux.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 3803bce commit 4fb5fd5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

git-commit.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ else
554554
# we need to check if there is anything to commit
555555
run_status >/dev/null
556556
fi
557-
if [ "$?" != "0" -a ! -f "$GIT_DIR/MERGE_HEAD" -a -z "$amend" ]
557+
if [ "$?" != "0" -a ! -f "$GIT_DIR/MERGE_HEAD" ]
558558
then
559559
rm -f "$GIT_DIR/COMMIT_EDITMSG" "$GIT_DIR/SQUASH_MSG"
560560
use_status_color=t

0 commit comments

Comments
 (0)