git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] show_one_mergetag: print non-parent in hex form.

From
HGHarald van Dijk via GitGitGadget <gitgitgadget@gmail.com>
Date
Feb 29, 2020, 13:07 UTC
Message-ID
<pull.568.git.1582981677312.gitgitgadget@gmail.com>
From: Harald van Dijk <harald@gigawatt.nl>

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 <harald@gigawatt.nl>
---
    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 harald@gigawatt.nl [harald@gigawatt.nl]
    
    Before, after a shallow clone of 
    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/:
    
    $ git show -s --show-signature
    commit a2f0b878c3ca531a1706cb2a8b079cea3b17bafc (grafted, HEAD -> master, origin/master, origin/HEAD)
    tag kbuild-fixes-v5.6-2 names a non-parent 꼋<CB>)/<B9><A5>u{^L<8A><B7>u^_A<B0><A1>^D<F8>
    No signature
    Author: Linus Torvalds <torvalds@linux-foundation.org>
    Date:   Thu Feb 27 11:26:33 2020 -0800
    [...]
    
    After:
    
    $ git show -s --show-signature
    commit a2f0b878c3ca531a1706cb2a8b079cea3b17bafc (grafted, HEAD -> master, origin/master, origin/HEAD)
    tag kbuild-fixes-v5.6-2 names a non-parent eabc8bcb292fb9a5757b0c8ab7751f41b0a104f8
    No signature
    Author: Linus Torvalds <torvalds@linux-foundation.org>
    Date:   Thu Feb 27 11:26:33 2020 -0800
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-568%2Fhvdijk%2Fmergetag-hex-form-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-568/hvdijk/mergetag-hex-form-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/568
 log-tree.c     |  2 +-
 t/t4202-log.sh | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/log-tree.c b/log-tree.c
index cae38dcc662..2a2db96d5ec 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -517,7 +517,7 @@ static int show_one_mergetag(struct commit *commit,
 			    "merged tag '%s'\n", tag->tag);
 	else if ((nth = which_parent(&tag->tagged->oid, commit)) < 0)
 		strbuf_addf(&verify_message, "tag %s names a non-parent %s\n",
-				    tag->tag, tag->tagged->oid.hash);
+				    tag->tag, oid_to_hex(&tag->tagged->oid));
 	else
 		strbuf_addf(&verify_message,
 			    "parent #%d, tagged '%s'\n", nth + 1, tag->tag);
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 192347a3e1f..20cb436c433 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -1634,6 +1634,26 @@ test_expect_success GPG 'log --graph --show-signature for merged tag' '
 	grep "^| | gpg: Good signature" actual
 '
 
+test_expect_success GPG 'log --graph --show-signature for merged tag in shallow clone' '
+	test_when_finished "git reset --hard && git checkout master" &&
+	git checkout -b plain-shallow master &&
+	echo aaa >bar &&
+	git add bar &&
+	git commit -m bar_commit &&
+	git checkout --detach master &&
+	echo bbb >baz &&
+	git add baz &&
+	git commit -m baz_commit &&
+	git tag -s -m signed_tag_msg signed_tag_shallow &&
+	hash=$(git rev-parse HEAD) &&
+	git checkout plain-shallow &&
+	git merge --no-ff -m msg signed_tag_shallow &&
+	git clone --depth 1 --no-local . shallow &&
+	test_when_finished "rm -rf shallow" &&
+	git -C shallow log --graph --show-signature -n1 plain-shallow >actual &&
+	grep "tag signed_tag_shallow names a non-parent $hash" actual
+'
+
 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
 	test_when_finished "git reset --hard && git checkout master" &&
 	test_config gpg.format x509 &&

base-commit: 2d2118b814c11f509e1aa76cb07110f7231668dc
-- 
gitgitgadget
Next: brian m. carlson
Message 1 of 5 in “show_one_mergetag: print non-parent in hex form.”
  1. show_one_mergetag: print non-parent in hex form.Harald van Dijk via GitGitGadget, Feb 29, 2020
  2. brian m. carlsonMar 1, 2020
  3. Martin ÅgrenMar 1, 2020
  4. Harald van DijkMar 1, 2020
  5. Martin ÅgrenMar 2, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.