In case of creating a non-merge commit, when just created tree object is ready to be committed, ensure that this tree object is not the same as the tree object of the parent commit. Signed-off-by: Dmitry V. Levin <ldv@xxxxxxxxxxxx> --- git-commit.sh | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/git-commit.sh b/git-commit.sh index 41538f1..9844691 100755 --- a/git-commit.sh +++ b/git-commit.sh @@ -629,6 +629,19 @@ then tree=$(GIT_INDEX_FILE="$TMP_INDEX" git write-tree) && rm -f "$TMP_INDEX" fi && + if test -n "$current" -a ! -f "$GIT_DIR/MERGE_HEAD" + then + if test "$tree" = "$(git rev-parse "$current${amend:+^}^{tree}" 2>/dev/null)" + then + if test -n "$amend" + then + echo >&2 'nothing to amend (use "git reset --soft HEAD^" to discard last commit)' + else + echo >&2 'nothing to commit' + fi + false + fi + fi && commit=$(git commit-tree $tree $PARENTS <"$GIT_DIR/COMMIT_MSG") && rlogm=$(sed -e 1q "$GIT_DIR"/COMMIT_MSG) && git update-ref -m "$GIT_REFLOG_ACTION: $rlogm" HEAD $commit "$current" && -- ldv - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html