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

Re: Should Git Tag trailer formatting work?

From
Brooke Kuhlmann <brooke@alchemists.io>
Date
Sep 6, 2024, 15:22 UTC
Message-ID
<249C7637-0032-4D53-A8A0-83935764334E@alchemists.io>
In-Reply-To
<20240906040434.GB4168449@coredump.intra.peff.net>
Hey Jeff, thanks.
Yeah, I can render trailer information when using your examples but *only* if I disable signing my tags. Here's what my global Git configuration looks like:
[tag]
  gpgSign = true
  sort = version:refname
...and here's a better example to demonstrate:

mkdir demo cd demo git init

touch one.txt git add . git commit --message "Added one" git tag 0.0.0 --message "Version 0.0.0" --trailer A:0

touch two.txt git add . git commit --message "Added two" git tag 0.0.1 --message "Version 0.0.1" --no-sign --trailer A:1

Notice how Version 0.0.0 creates a signed tag but Version 0.0.1 forces the tag to not be signed. I can then run the following:
git tag --list \
        --format="%(refname:short)|%(taggerdate:short)|%(taggername)|%(subject)|%(trailers:key=A)" \
       | column -s "|" -t
...to produce this output:

0.0.0 2024-09-06 Brooke Kuhlmann Version 0.0.0 0.0.1 2024-09-06 Brooke Kuhlmann Version 0.0.1 A: 1

So I can see that Git tag trailers are working but only if my tags are *not* signed. Here's what each tag looks like when I cat them out:
git cat-file tag 0.0.0

object ad13b82ff41d5698cfb03a06b95e6e5a98386ed4 type commit tag 0.0.0 tagger Brooke Kuhlmann <brooke@alchemists.io> 1725635799 -0600

Version 0.0.0
A: 0
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEE0UiFiNLe33PmLweh8rxJvE/7mkgFAmbbHNcACgkQ8rxJvE/7 mkiBFRAAlaFfRQK6fK4J9z49tF9OR0vMJRygtR4LZE1z2JmPUTTapKf8meIFIFxU GeIAfcD8aofgV6WeGDCIaL0Kg0quInlWA19Y+Yqv5ZL3J6dEkWu8R9hmgKK8jCPo U+EtaCSv0cM+ZmN4paCM9ZirdvnTQY5gaTJ9D+xreklaqZSryrAFfMH6UdsGnFtQ KkR+G2B9RCuD2loV5KBIttYAhnGf54xJxfGFcZiIGD/qErWWgABIN6zDP5SHPMXz NOjDDLh3ZUA0D1nXqxS7Aq4fe4wrRIGmtLs+Kh+fnHLuhfBh7vqrkUBydGjiGuc3 bQVOHCxe3kpfqS+P/12aGfc4yTWdL89qBWZGCEtTPw4wqLAOvzMzJ6ffc6TKdz6r mNsV4ZWKwigS6KpCyJt1ecWq3jAZIPwx2ADsw/JQm82LfcTrn3d3nIV/0qpM0oVL jOoZh+ozPq2bWZWqHk6PfaW2m0dKN8w9o9paJGUdyj5KjolLtak7sY067ATbIFXM hdkpFAhvc6VhFNIcfYStLd1yJggCigpXbtx/+QG/PMMx6wMwcz0kko1KfWW4fxs0 SiEbHO3Ja0o1DG31QFb54MOi8I7n8xVgtckSj+dr+/b4hEv8b1BS5x61NJaTsxu4 PQcWEburYAPeFkbmT/ji52vCLOetQ4GPEc2+sDPvZioxQgUuhzk= =v8eJ -----END PGP SIGNATURE-----

git cat-file tag 0.0.1

object e10b4d0578a5b309aac31d036a2d33a7389eff2e type commit tag 0.0.1 tagger Brooke Kuhlmann <brooke@alchemists.io> 1725635858 -0600

Version 0.0.1
A: 1
So it seems like signing my tags is causing trailer information to be lost?
Show 46 quoted lines
> On Sep 5, 2024, at 10:04 PM, Jeff King <peff@peff.net> wrote:
> 
> On Thu, Sep 05, 2024 at 10:05:24AM -0600, Brooke Kuhlmann wrote:
> 
>> With the recent release of Git 2.46.0, the ability to add trailers to tags was added which is great! However, when attempting to list and format trailer information, I don't see the trailer information display using the following Bash code:
>> 
>> ``` 
>> git tag --list \
>>        --color \
>>        --format="%(color:yellow)%(refname:short)%(color:reset)|%(taggerdate:short)|%(color:blue)%(color:bold)%(taggername)%(color:reset)|%(subject)|%(trailers:key=Insertions)" \
>>        | column -s"|" -t
>> ```
> 
> This seems to work fine for me. If I do:
> 
>  {
> 	echo "Version 0.0.0"
> 	echo
> 	echo "An example."
> 	echo
> 	echo "Insertions: 10"
>  } >input
>  git tag -F input foo
> 
> then your example above produces:
> 
>  foo  2024-09-06  Jeff King  Version 0.0.0  Insertions: 10
> 
> I wonder if the contents of the tag are not exactly as you expect, and
> that is fooling the trailer parser (which relies on some heuristics to
> find the right spot). Can you show us the output of "git cat-file tag
> <some-tag>"? Mine looks like:
> 
>  $ git cat-file tag foo
>  object af1c73c21ab34cfbdc86da838acacc6e45ccd264
>  type commit
>  tag foo
>  tagger Jeff King <peff@peff.net> 1725595316 -0400
> 
>  Version 0.0.0
> 
>  An example.
> 
>  Insertions: 10
> 
> -Peff
Previous: Jeff KingNext: Jeff King
Message 3 of 5 in “Should Git Tag trailer formatting work?”
  1. Brooke KuhlmannSep 5, 2024
  2. Jeff KingSep 6, 2024
  3. Brooke KuhlmannSep 6, 2024
  4. Jeff KingSep 6, 2024
  5. Brooke KuhlmannSep 6, 2024

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.