git-commit: Allow to amend a merge commit that does not change the tree
Normally, it should not be allowed to generate an empty commit. A merge commit generated with git 'merge -s ours' does not change the tree (along the first parent), but merges are not "empty" even if they do not change the tree. Hence, commit8588452ceballowed to amend a merge commit that does not change the tree, but4fb5fd5d30disallowed it again in an attempt to avoid that an existing commit is amended such that it becomes empty. With this change, a commit can be edited (create a new one or amend an existing one) either if there are changes or if there are at least two parents. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
afcc4f7767
commit
13aba1e514
@@ -515,13 +515,16 @@ else
|
||||
# we need to check if there is anything to commit
|
||||
run_status >/dev/null
|
||||
fi
|
||||
if [ "$?" != "0" -a ! -f "$GIT_DIR/MERGE_HEAD" ]
|
||||
then
|
||||
case "$?,$PARENTS" in
|
||||
0,* | *,-p' '?*-p' '?*)
|
||||
# a merge commit can record the same tree as its parent.
|
||||
;;
|
||||
*)
|
||||
rm -f "$GIT_DIR/COMMIT_EDITMSG" "$GIT_DIR/SQUASH_MSG"
|
||||
use_status_color=t
|
||||
run_status
|
||||
exit 1
|
||||
fi
|
||||
esac
|
||||
|
||||
case "$no_edit" in
|
||||
'')
|
||||
|
||||
Reference in New Issue
Block a user