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 <gitster@pobox.com>

Junio C Hamano committed Nov 7, 2011 at 14:45 UTC 274a5c06d525da8c9720ae60454fba6779523c52
2 files changed +15 -4
builtin/merge.c
+10 -3
@@ -1045,9 +1045,16 @@ static void write_merge_state(void)
1045 struct commit_list *j;
1046 struct strbuf buf = STRBUF_INIT;
1047
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 + }
1058 fd = open(git_path("MERGE_HEAD"), O_WRONLY | O_CREAT, 0666);
1059 if (fd < 0)
1060 die_errno(_("Could not open '%s' for writing"),
t/t7600-merge.sh
+5 -1
@@ -96,7 +96,11 @@ verify_parents () {
96
97 verify_mergeheads () {
98 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
104 }
105
106 verify_no_mergehead () {