git-save: don't create a redundant new commits with no changes

If the newly created save tree is identical to the parent commit tree,
don't bother creating a new commit.  We are already fully up-to-date.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Linus Torvalds 2014-03-11 14:55:43 -07:00 committed by Dirk Hohndel
parent 4af254776e
commit 809a6e784c

View file

@ -774,6 +774,11 @@ static int create_new_commit(git_repository *repo, const char *branch, git_oid *
case 0: case 0:
if (git_reference_peel(&parent, ref, GIT_OBJ_COMMIT)) if (git_reference_peel(&parent, ref, GIT_OBJ_COMMIT))
return report_error("Unable to look up parent in branch '%s'", branch); return report_error("Unable to look up parent in branch '%s'", branch);
/* If the parent commit has the same tree ID, do nothing */
if (git_oid_equal(tree_id, git_commit_tree_id((const git_commit *) parent)))
return 0;
/* all good */ /* all good */
break; break;
} }