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

Possible bug regarding trailers

From
Eeric.frederich@siemens.com <eric.frederich@siemens.com>
Date
Jun 15, 2023, 17:46 UTC
Message-ID
<PH7PR07MB9467452EBAFAB2C825295C0C8C5BA@PH7PR07MB9467.namprd07.prod.outlook.com>
I am able to produce a commit with a trailer which does not show up in:
    `git log --format="%(trailers:key=old-scm-change-id,valueonly,separator=%x2c) %H %T" HEAD`
But does show up in:
    `git cat-file commit HEAD | git interpret-trailers --parse`

The following script reproduces the issue. It deletes directory /tmp/foo (from previous runs if you want to change something and run it again) then creates a new git directory in /tmp/foo and operates within there. The comments at the bottom of the script were from run of the script. You'll see the "WE WILL SEE THIS TRAILER" but you will not see the "THIS TRAILER GETS LOST" even though they both show up on an explicit call to `git interpret-trailers --parse`

I'm looking for a reliable way to store some meta-data from an old SCM system as we migrate to Git. I'd prefer to utilize Git's native trailers and not have to resort to using a (foreign to Git) sqlite database or something.

Thanks, ~Eric

#!/bin/bash

rm -rf /tmp/foo mkdir /tmp/foo cd /tmp/foo git init git config user.email a@b.com git config user.name "example" git config commit.gpgSign false

echo "CHANGE" >> README.md git add . git commit -m "A bad commit

--- let's mess stuff up ---

Have fun " --trailer "old-scm-change-id:THIS TRAILER GETS LOST"

echo "CHANGE" >> README.md git add . git commit -m "A good commit

*** no problem here ***

Have fun " --trailer "old-scm-change-id:WE WILL SEE THIS TRAILER"

echo "******************** git log ********************" git log

echo "******************** git cat-file commit HEAD^ ********************" git cat-file commit HEAD^

echo "******************** git cat-file commit HEAD ********************" git cat-file commit HEAD

echo "*****" echo "*****" echo "*****" echo "*****" echo "*****"

echo -e "\n\n***** git cat-file commit HEAD^ | git interpret-trailers --parse *****" git cat-file commit HEAD^ | git interpret-trailers --parse

echo -e "\n\n***** git cat-file commit HEAD | git interpret-trailers --parse *****" git cat-file commit HEAD | git interpret-trailers --parse

echo -e "\n\n******************** git log w/ trailers in format ********************" git log --format="%(trailers:key=old-scm-change-id,valueonly,separator=%x2c) %H %T" HEAD

echo -e "\n\n******************** git version ********************" git version

# OUTPUT:

# Initialized empty Git repository in /tmp/foo/.git/ # [main (root-commit) 62d1150] A bad commit # 1 file changed, 1 insertion(+) # create mode 100644 README.md # [main 0deff83] A good commit # 1 file changed, 1 insertion(+) # ******************** git log ******************** # commit 0deff83a2955ab5bb8aef24eca77e5399feabacc # Author: example <a@b.com> # Date: Thu Jun 15 13:39:37 2023 -0400 # # A good commit # # *** no problem here *** # # Have fun # # old-scm-change-id: WE WILL SEE THIS TRAILER # # commit 62d11500db250440c190ebe60945789e13fb0bbf # Author: example <a@b.com> # Date: Thu Jun 15 13:39:37 2023 -0400 # # A bad commit # # old-scm-change-id: THIS TRAILER GETS LOST # # --- let's mess stuff up --- # # Have fun # ******************** git cat-file commit HEAD^ ******************** # tree 1dd017bdd070190005e5e162d87afebcd61e0fa8 # author example <a@b.com> 1686850777 -0400 # committer example <a@b.com> 1686850777 -0400 # # A bad commit # # old-scm-change-id: THIS TRAILER GETS LOST # # --- let's mess stuff up --- # # Have fun # ******************** git cat-file commit HEAD ******************** # tree cd83b4c038415891bff254e2954113df2f78aa62 # parent 62d11500db250440c190ebe60945789e13fb0bbf # author example <a@b.com> 1686850777 -0400 # committer example <a@b.com> 1686850777 -0400 # # A good commit # # *** no problem here *** # # Have fun # # old-scm-change-id: WE WILL SEE THIS TRAILER # ***** # ***** # ***** # ***** # ***** # # # ***** git cat-file commit HEAD^ | git interpret-trailers --parse ***** # old-scm-change-id: THIS TRAILER GETS LOST # # # ***** git cat-file commit HEAD | git interpret-trailers --parse ***** # old-scm-change-id: WE WILL SEE THIS TRAILER # # # ******************** git log w/ trailers in format ******************** # WE WILL SEE THIS TRAILER 0deff83a2955ab5bb8aef24eca77e5399feabacc cd83b4c038415891bff254e2954113df2f78aa62 # 62d11500db250440c190ebe60945789e13fb0bbf 1dd017bdd070190005e5e162d87afebcd61e0fa8 # # # ******************** git version ******************** # git version 2.41.0.187.g15d354cc3d

Next: Kristoffer Haugsbakk
Message 1 of 11 in “Possible bug regarding trailers”
  1. eric.frederich@siemens.comJun 15, 2023
  2. Kristoffer HaugsbakkJun 15, 2023
  3. Jeff KingJun 16, 2023
  4. Christian CouderJun 16, 2023
  5. commit: pass --no-divider to interpret-trailersJeff King, Jun 17, 2023
  6. Christian CouderJun 19, 2023
  7. Linus ArverJun 16, 2023
  8. Jeff KingJun 17, 2023
  9. eric.frederich@siemens.comJun 16, 2023
  10. Christian CouderJun 16, 2023
  11. Linus ArverJun 16, 2023

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.