From 809a6e784c61364b2f2078cdd1acf452da7550a1 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 11 Mar 2014 14:55:43 -0700 Subject: [PATCH] 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 Signed-off-by: Dirk Hohndel --- save-git.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/save-git.c b/save-git.c index ef6ce2755..04ff87467 100644 --- a/save-git.c +++ b/save-git.c @@ -774,6 +774,11 @@ static int create_new_commit(git_repository *repo, const char *branch, git_oid * case 0: if (git_reference_peel(&parent, ref, GIT_OBJ_COMMIT)) 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 */ break; }