Skip to content

Commit 237a281

Browse files
hvdijkgitster
authored andcommitted
show_one_mergetag: print non-parent in hex form.
When a mergetag names a non-parent, which can occur after a shallow clone, its hash was previously printed as raw data. Print it in hex form instead. Signed-off-by: Harald van Dijk <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d9589d4 commit 237a281

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

log-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ static int show_one_mergetag(struct commit *commit,
514514
"merged tag '%s'\n", tag->tag);
515515
else if ((nth = which_parent(&tag->tagged->oid, commit)) < 0)
516516
strbuf_addf(&verify_message, "tag %s names a non-parent %s\n",
517-
tag->tag, tag->tagged->oid.hash);
517+
tag->tag, oid_to_hex(&tag->tagged->oid));
518518
else
519519
strbuf_addf(&verify_message,
520520
"parent #%d, tagged '%s'\n", nth + 1, tag->tag);

t/t4202-log.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,6 +1596,26 @@ test_expect_success GPG 'log --graph --show-signature for merged tag' '
15961596
grep "^| | gpg: Good signature" actual
15971597
'
15981598

1599+
test_expect_success GPG 'log --graph --show-signature for merged tag in shallow clone' '
1600+
test_when_finished "git reset --hard && git checkout master" &&
1601+
git checkout -b plain-shallow master &&
1602+
echo aaa >bar &&
1603+
git add bar &&
1604+
git commit -m bar_commit &&
1605+
git checkout --detach master &&
1606+
echo bbb >baz &&
1607+
git add baz &&
1608+
git commit -m baz_commit &&
1609+
git tag -s -m signed_tag_msg signed_tag_shallow &&
1610+
hash=$(git rev-parse HEAD) &&
1611+
git checkout plain-shallow &&
1612+
git merge --no-ff -m msg signed_tag_shallow &&
1613+
git clone --depth 1 --no-local . shallow &&
1614+
test_when_finished "rm -rf shallow" &&
1615+
git -C shallow log --graph --show-signature -n1 plain-shallow >actual &&
1616+
grep "tag signed_tag_shallow names a non-parent $hash" actual
1617+
'
1618+
15991619
test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
16001620
test_when_finished "git reset --hard && git checkout master" &&
16011621
test_config gpg.format x509 &&

0 commit comments

Comments
 (0)