Skip to content

Commit

Permalink
merge: record tag objects without peeling in MERGE_HEAD
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Nov 8, 2011
1 parent ae8e4c9 commit 274a5c0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
13 changes: 10 additions & 3 deletions builtin/merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -1045,9 +1045,16 @@ static void write_merge_state(void)
struct commit_list *j;
struct strbuf buf = STRBUF_INIT;

for (j = remoteheads; j; j = j->next)
strbuf_addf(&buf, "%s\n",
sha1_to_hex(j->item->object.sha1));
for (j = remoteheads; j; j = j->next) {
unsigned const char *sha1;
struct commit *c = j->item;
if (c->util && merge_remote_util(c)->obj) {
sha1 = merge_remote_util(c)->obj->sha1;
} else {
sha1 = c->object.sha1;
}
strbuf_addf(&buf, "%s\n", sha1_to_hex(sha1));
}
fd = open(git_path("MERGE_HEAD"), O_WRONLY | O_CREAT, 0666);
if (fd < 0)
die_errno(_("Could not open '%s' for writing"),
Expand Down
6 changes: 5 additions & 1 deletion t/t7600-merge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ verify_parents () {

verify_mergeheads () {
printf '%s\n' "$@" >mergehead.expected &&
test_cmp mergehead.expected .git/MERGE_HEAD
while read sha1 rest
do
git rev-parse $sha1
done <.git/MERGE_HEAD >mergehead.actual &&
test_cmp mergehead.expected mergehead.actual
}

verify_no_mergehead () {
Expand Down

0 comments on commit 274a5c0

Please sign in to comment.