summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-12-05 12:52:46 -0800
committerJunio C Hamano <gitster@pobox.com>2019-12-05 12:52:46 -0800
commitc9208597a986509e6ce9b3c7936fd7a2b3bb3e43 (patch)
treeb0be7ecbb4410cc0243d5423427928fb248111e8 /sequencer.c
parent36fd304d819d412adf1ed81d6a983dabb28bfc9b (diff)
parent2d05ef2778b99e05e6a8a40c5b8d59a3c4ab1274 (diff)
downloadgit-c9208597a986509e6ce9b3c7936fd7a2b3bb3e43.tar.gz
Merge branch 'pw/sequencer-compare-with-right-parent-to-check-empty-commits'
The sequencer machinery compared the HEAD and the state it is attempting to commit to decide if the result would be a no-op commit, even when amending a commit, which was incorrect, and has been corrected. * pw/sequencer-compare-with-right-parent-to-check-empty-commits: sequencer: fix empty commit check when amending
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/sequencer.c b/sequencer.c
index e65076f221..d18aba62f5 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1350,11 +1350,27 @@ static int try_to_commit(struct repository *r,
goto out;
}
- if (!(flags & ALLOW_EMPTY) && oideq(current_head ?
- get_commit_tree_oid(current_head) :
- the_hash_algo->empty_tree, &tree)) {
- res = 1; /* run 'git commit' to display error message */
- goto out;
+ if (!(flags & ALLOW_EMPTY)) {
+ struct commit *first_parent = current_head;
+
+ if (flags & AMEND_MSG) {
+ if (current_head->parents) {
+ first_parent = current_head->parents->item;
+ if (repo_parse_commit(r, first_parent)) {
+ res = error(_("could not parse HEAD commit"));
+ goto out;
+ }
+ } else {
+ first_parent = NULL;
+ }
+ }
+ if (oideq(first_parent
+ ? get_commit_tree_oid(first_parent)
+ : the_hash_algo->empty_tree,
+ &tree)) {
+ res = 1; /* run 'git commit' to display error message */
+ goto out;
+ }
}
if (find_hook("prepare-commit-msg")) {