Skip to content

Commit 274a5c0

Browse files
committed
merge: record tag objects without peeling in MERGE_HEAD
Otherwise, "git commit" wouldn't have a way to tell that we were in the middle of merging an annotated or signed tag, not a plain commit, after "git merge" stops to ask the user to resolve conflicts. Signed-off-by: Junio C Hamano <[email protected]>
1 parent ae8e4c9 commit 274a5c0

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

builtin/merge.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,9 +1045,16 @@ static void write_merge_state(void)
10451045
struct commit_list *j;
10461046
struct strbuf buf = STRBUF_INIT;
10471047

1048-
for (j = remoteheads; j; j = j->next)
1049-
strbuf_addf(&buf, "%s\n",
1050-
sha1_to_hex(j->item->object.sha1));
1048+
for (j = remoteheads; j; j = j->next) {
1049+
unsigned const char *sha1;
1050+
struct commit *c = j->item;
1051+
if (c->util && merge_remote_util(c)->obj) {
1052+
sha1 = merge_remote_util(c)->obj->sha1;
1053+
} else {
1054+
sha1 = c->object.sha1;
1055+
}
1056+
strbuf_addf(&buf, "%s\n", sha1_to_hex(sha1));
1057+
}
10511058
fd = open(git_path("MERGE_HEAD"), O_WRONLY | O_CREAT, 0666);
10521059
if (fd < 0)
10531060
die_errno(_("Could not open '%s' for writing"),

t/t7600-merge.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ verify_parents () {
9696

9797
verify_mergeheads () {
9898
printf '%s\n' "$@" >mergehead.expected &&
99-
test_cmp mergehead.expected .git/MERGE_HEAD
99+
while read sha1 rest
100+
do
101+
git rev-parse $sha1
102+
done <.git/MERGE_HEAD >mergehead.actual &&
103+
test_cmp mergehead.expected mergehead.actual
100104
}
101105

102106
verify_no_mergehead () {

0 commit comments

Comments
 (0)