Skip to content

Commit d041ffa

Browse files
committed
log --show-signature: reword the common two-head merge case
While identifying the commit merged to our history as "parent #2" is technically correct, we will never say "parent #1" (as that is the tip of our history before the merge is made), and we rarely would say "parent #3" (which would mean the merge is an octopus), especially when responding to a request to pull a signed tag. Treat the most common case to merge a single commit specially, and just say "merged tag '<tagname>'" instead. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 824958e commit d041ffa

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

log-tree.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,13 @@ static int which_parent(const unsigned char *sha1, const struct commit *commit)
456456
return -1;
457457
}
458458

459+
static int is_common_merge(const struct commit *commit)
460+
{
461+
return (commit->parents
462+
&& commit->parents->next
463+
&& !commit->parents->next->next);
464+
}
465+
459466
static void show_one_mergetag(struct rev_info *opt,
460467
struct commit_extra_header *extra,
461468
struct commit *commit)
@@ -474,6 +481,11 @@ static void show_one_mergetag(struct rev_info *opt,
474481
strbuf_init(&verify_message, 256);
475482
if (parse_tag_buffer(tag, extra->value, extra->len))
476483
strbuf_addstr(&verify_message, "malformed mergetag\n");
484+
else if (is_common_merge(commit) &&
485+
!hashcmp(tag->tagged->sha1,
486+
commit->parents->next->item->object.sha1))
487+
strbuf_addf(&verify_message,
488+
"merged tag '%s'\n", tag->tag);
477489
else if ((nth = which_parent(tag->tagged->sha1, commit)) < 0)
478490
strbuf_addf(&verify_message, "tag %s names a non-parent %s\n",
479491
tag->tag, tag->tagged->sha1);

0 commit comments

Comments
 (0)