{"thread":{"id":"62066","subject":"Should Git Tag trailer formatting work?","startedAt":"2024-09-05T16:05:36Z","lastAt":"2024-09-06T22:56:13Z","messageCount":5,"participants":["Brooke Kuhlmann","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"502253","messageId":"E46F3EFF-66D1-4B29-BCF3-6FFAB2504411@alchemists.io","threadId":"62066","inReplyTo":null,"subject":"Should Git Tag trailer formatting work?","fromName":"Brooke Kuhlmann","fromEmail":"brooke@alchemists.io","sentAt":"2024-09-05T16:05:24Z","receivedAt":"2024-09-05T16:05:36Z","isPatch":false,"sender":{"key":"brooke@alchemists.io","avatar":"https://gravatar.com/avatar/4bd27d52fe87760d2bde1d384f0139eb81013709a0cf27ce654d48a7852727fa?d=mp&s=160"},"body":"Hello. 👋\n\nWith 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:\n\n``` \ngit tag --list \\\n        --color \\\n        --format=\"%(color:yellow)%(refname:short)%(color:reset)|%(taggerdate:short)|%(color:blue)%(color:bold)%(taggername)%(color:reset)|%(subject)|%(trailers:key=Insertions)\" \\\n        | column -s\"|\" -t\n```\n\nNotice that I'm using the same syntax (`%(trailers:key=Insertions)`) as used in the git for-each-ref (https://git-scm.com/docs/git-for-each-ref#Documentation/git-for-each-ref.txt-rawsize) documentation. If it helps, I also create my Git tag using `git tag` and formatting my message as follows:\n\n``` \nVersion 0.0.0\n\nAn example.\n\nInsertions: 10\n```\n\nShouldn't the formatting of my git tags pick up the \"Insertions\" trailer key and print it? Is this a bug or am I doing something wrong?\n\nThanks!"},{"id":"502302","messageId":"20240906040434.GB4168449@coredump.intra.peff.net","threadId":"62066","inReplyTo":"E46F3EFF-66D1-4B29-BCF3-6FFAB2504411@alchemists.io","subject":"Re: Should Git Tag trailer formatting work?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-09-06T04:04:34Z","receivedAt":"2024-09-06T04:04:35Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Sep 05, 2024 at 10:05:24AM -0600, Brooke Kuhlmann wrote:\n\n> 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:\n> \n> ``` \n> git tag --list \\\n>         --color \\\n>         --format=\"%(color:yellow)%(refname:short)%(color:reset)|%(taggerdate:short)|%(color:blue)%(color:bold)%(taggername)%(color:reset)|%(subject)|%(trailers:key=Insertions)\" \\\n>         | column -s\"|\" -t\n> ```\n\nThis seems to work fine for me. If I do:\n\n  {\n\techo \"Version 0.0.0\"\n\techo\n\techo \"An example.\"\n\techo\n\techo \"Insertions: 10\"\n  } >input\n  git tag -F input foo\n\nthen your example above produces:\n\n  foo  2024-09-06  Jeff King  Version 0.0.0  Insertions: 10\n\nI wonder if the contents of the tag are not exactly as you expect, and\nthat is fooling the trailer parser (which relies on some heuristics to\nfind the right spot). Can you show us the output of \"git cat-file tag\n<some-tag>\"? Mine looks like:\n\n  $ git cat-file tag foo\n  object af1c73c21ab34cfbdc86da838acacc6e45ccd264\n  type commit\n  tag foo\n  tagger Jeff King <peff@peff.net> 1725595316 -0400\n  \n  Version 0.0.0\n  \n  An example.\n  \n  Insertions: 10\n\n-Peff\n"},{"id":"502332","messageId":"249C7637-0032-4D53-A8A0-83935764334E@alchemists.io","threadId":"62066","inReplyTo":"20240906040434.GB4168449@coredump.intra.peff.net","subject":"Re: Should Git Tag trailer formatting work?","fromName":"Brooke Kuhlmann","fromEmail":"brooke@alchemists.io","sentAt":"2024-09-06T15:22:33Z","receivedAt":"2024-09-06T15:22:46Z","isPatch":false,"sender":{"key":"brooke@alchemists.io","avatar":"https://gravatar.com/avatar/4bd27d52fe87760d2bde1d384f0139eb81013709a0cf27ce654d48a7852727fa?d=mp&s=160"},"body":"Hey Jeff, thanks.\n\nYeah, 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:\n\n[tag]\n  gpgSign = true\n  sort = version:refname\n\n...and here's a better example to demonstrate:\n\nmkdir demo\ncd demo\ngit init\n\ntouch one.txt\ngit add .\ngit commit --message \"Added one\"\ngit tag 0.0.0 --message \"Version 0.0.0\" --trailer A:0\n\ntouch two.txt\ngit add .\ngit commit --message \"Added two\"\ngit tag 0.0.1 --message \"Version 0.0.1\" --no-sign --trailer A:1\n\nNotice 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:\n\ngit tag --list \\\n        --format=\"%(refname:short)|%(taggerdate:short)|%(taggername)|%(subject)|%(trailers:key=A)\" \\\n       | column -s \"|\" -t\n\n...to produce this output:\n\n0.0.0  2024-09-06  Brooke Kuhlmann  Version 0.0.0\n0.0.1  2024-09-06  Brooke Kuhlmann  Version 0.0.1  A: 1\n\nSo 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:\n\ngit cat-file tag 0.0.0\n\nobject ad13b82ff41d5698cfb03a06b95e6e5a98386ed4\ntype commit\ntag 0.0.0\ntagger Brooke Kuhlmann <brooke@alchemists.io> 1725635799 -0600\n\nVersion 0.0.0\n\nA: 0\n-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEE0UiFiNLe33PmLweh8rxJvE/7mkgFAmbbHNcACgkQ8rxJvE/7\nmkiBFRAAlaFfRQK6fK4J9z49tF9OR0vMJRygtR4LZE1z2JmPUTTapKf8meIFIFxU\nGeIAfcD8aofgV6WeGDCIaL0Kg0quInlWA19Y+Yqv5ZL3J6dEkWu8R9hmgKK8jCPo\nU+EtaCSv0cM+ZmN4paCM9ZirdvnTQY5gaTJ9D+xreklaqZSryrAFfMH6UdsGnFtQ\nKkR+G2B9RCuD2loV5KBIttYAhnGf54xJxfGFcZiIGD/qErWWgABIN6zDP5SHPMXz\nNOjDDLh3ZUA0D1nXqxS7Aq4fe4wrRIGmtLs+Kh+fnHLuhfBh7vqrkUBydGjiGuc3\nbQVOHCxe3kpfqS+P/12aGfc4yTWdL89qBWZGCEtTPw4wqLAOvzMzJ6ffc6TKdz6r\nmNsV4ZWKwigS6KpCyJt1ecWq3jAZIPwx2ADsw/JQm82LfcTrn3d3nIV/0qpM0oVL\njOoZh+ozPq2bWZWqHk6PfaW2m0dKN8w9o9paJGUdyj5KjolLtak7sY067ATbIFXM\nhdkpFAhvc6VhFNIcfYStLd1yJggCigpXbtx/+QG/PMMx6wMwcz0kko1KfWW4fxs0\nSiEbHO3Ja0o1DG31QFb54MOi8I7n8xVgtckSj+dr+/b4hEv8b1BS5x61NJaTsxu4\nPQcWEburYAPeFkbmT/ji52vCLOetQ4GPEc2+sDPvZioxQgUuhzk=\n=v8eJ\n-----END PGP SIGNATURE-----\n\n\n\ngit cat-file tag 0.0.1\n\nobject e10b4d0578a5b309aac31d036a2d33a7389eff2e\ntype commit\ntag 0.0.1\ntagger Brooke Kuhlmann <brooke@alchemists.io> 1725635858 -0600\n\nVersion 0.0.1\n\nA: 1\n\nSo it seems like signing my tags is causing trailer information to be lost?\n\n\n> On Sep 5, 2024, at 10:04 PM, Jeff King <peff@peff.net> wrote:\n> \n> On Thu, Sep 05, 2024 at 10:05:24AM -0600, Brooke Kuhlmann wrote:\n> \n>> 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:\n>> \n>> ``` \n>> git tag --list \\\n>>        --color \\\n>>        --format=\"%(color:yellow)%(refname:short)%(color:reset)|%(taggerdate:short)|%(color:blue)%(color:bold)%(taggername)%(color:reset)|%(subject)|%(trailers:key=Insertions)\" \\\n>>        | column -s\"|\" -t\n>> ```\n> \n> This seems to work fine for me. If I do:\n> \n>  {\n> \techo \"Version 0.0.0\"\n> \techo\n> \techo \"An example.\"\n> \techo\n> \techo \"Insertions: 10\"\n>  } >input\n>  git tag -F input foo\n> \n> then your example above produces:\n> \n>  foo  2024-09-06  Jeff King  Version 0.0.0  Insertions: 10\n> \n> I wonder if the contents of the tag are not exactly as you expect, and\n> that is fooling the trailer parser (which relies on some heuristics to\n> find the right spot). Can you show us the output of \"git cat-file tag\n> <some-tag>\"? Mine looks like:\n> \n>  $ git cat-file tag foo\n>  object af1c73c21ab34cfbdc86da838acacc6e45ccd264\n>  type commit\n>  tag foo\n>  tagger Jeff King <peff@peff.net> 1725595316 -0400\n> \n>  Version 0.0.0\n> \n>  An example.\n> \n>  Insertions: 10\n> \n> -Peff\n\n"},{"id":"502363","messageId":"20240906215054.GA1149961@coredump.intra.peff.net","threadId":"62066","inReplyTo":"249C7637-0032-4D53-A8A0-83935764334E@alchemists.io","subject":"Re: Should Git Tag trailer formatting work?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-09-06T21:50:54Z","receivedAt":"2024-09-06T21:51:01Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Sep 06, 2024 at 09:22:33AM -0600, Brooke Kuhlmann wrote:\n\n> Yeah, I can render trailer information when using your examples but\n> *only* if I disable signing my tags. Here's what my global Git\n> configuration looks like:\n\nAh, OK, that makes sense. We have to parse the trailers from the end,\nand the parser is not prepared to handle tags' inline signatures (in\ncommits, the signatures are embedded in headers, so the trailer parser\ndoesn't have to worry about them).\n\nI have a rough patch, but it requires making an extra copy of the tag\nbuffer, since the trailer API needs a NUL-terminated string. I'll see if\nI can clean that up to let us parse it in place, and should send\nsomething out in a day or so.\n\n-Peff\n"},{"id":"502375","messageId":"3A01E3C6-0AB5-4C0D-AA76-E5EE6A5AFA55@alchemists.io","threadId":"62066","inReplyTo":"20240906215054.GA1149961@coredump.intra.peff.net","subject":"Re: Should Git Tag trailer formatting work?","fromName":"Brooke Kuhlmann","fromEmail":"brooke@alchemists.io","sentAt":"2024-09-06T22:56:00Z","receivedAt":"2024-09-06T22:56:13Z","isPatch":false,"sender":{"key":"brooke@alchemists.io","avatar":"https://gravatar.com/avatar/4bd27d52fe87760d2bde1d384f0139eb81013709a0cf27ce654d48a7852727fa?d=mp&s=160"},"body":"Thanks! Yeah, that'd be great. Will look forward to checking out the changes.\n\n> On Sep 6, 2024, at 3:50 PM, Jeff King <peff@peff.net> wrote:\n> \n> On Fri, Sep 06, 2024 at 09:22:33AM -0600, Brooke Kuhlmann wrote:\n> \n>> Yeah, I can render trailer information when using your examples but\n>> *only* if I disable signing my tags. Here's what my global Git\n>> configuration looks like:\n> \n> Ah, OK, that makes sense. We have to parse the trailers from the end,\n> and the parser is not prepared to handle tags' inline signatures (in\n> commits, the signatures are embedded in headers, so the trailer parser\n> doesn't have to worry about them).\n> \n> I have a rough patch, but it requires making an extra copy of the tag\n> buffer, since the trailer API needs a NUL-terminated string. I'll see if\n> I can clean that up to let us parse it in place, and should send\n> something out in a day or so.\n> \n> -Peff\n\n"}]}