Skip to content

Commit d25a265

Browse files
committed
Merge branch 'nd/maint-autofix-tag-in-head' into maint
* nd/maint-autofix-tag-in-head: Accept tags in HEAD or MERGE_HEAD merge: remove global variable head[] merge: use return value of resolve_ref() to determine if HEAD is invalid merge: keep stash[] a local variable Conflicts: builtin/merge.c
2 parents e63f87a + baf18fc commit d25a265

File tree

7 files changed

+93
-65
lines changed

7 files changed

+93
-65
lines changed

builtin/commit.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
13921392
if (get_sha1("HEAD", sha1))
13931393
current_head = NULL;
13941394
else {
1395-
current_head = lookup_commit(sha1);
1395+
current_head = lookup_commit_or_die(sha1, "HEAD");
13961396
if (!current_head || parse_commit(current_head))
13971397
die(_("could not parse HEAD commit"));
13981398
}
@@ -1424,6 +1424,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
14241424
pptr = &commit_list_insert(c->item, pptr)->next;
14251425
} else if (whence == FROM_MERGE) {
14261426
struct strbuf m = STRBUF_INIT;
1427+
struct commit *commit;
14271428
FILE *fp;
14281429

14291430
if (!reflog_msg)
@@ -1437,7 +1438,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
14371438
unsigned char sha1[20];
14381439
if (get_sha1_hex(m.buf, sha1) < 0)
14391440
die(_("Corrupt MERGE_HEAD file (%s)"), m.buf);
1440-
pptr = &commit_list_insert(lookup_commit(sha1), pptr)->next;
1441+
commit = lookup_commit_or_die(sha1, "MERGE_HEAD");
1442+
pptr = &commit_list_insert(commit, pptr)->next;
14411443
}
14421444
fclose(fp);
14431445
strbuf_release(&m);

builtin/fmt-merge-msg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ static int do_fmt_merge_msg(int merge_title, struct strbuf *in,
293293
struct commit *head;
294294
struct rev_info rev;
295295

296-
head = lookup_commit(head_sha1);
296+
head = lookup_commit_or_die(head_sha1, "HEAD");
297297
init_revisions(&rev, NULL);
298298
rev.commit_format = CMIT_FMT_ONELINE;
299299
rev.ignore_merges = 1;

0 commit comments

Comments
 (0)