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

Re: Possible bug regarding trailers

From
Christian Couder <christian.couder@gmail.com>
Date
Jun 16, 2023, 18:37 UTC
Message-ID
<CAP8UFD22tPfP37LU8tveHmZPzj7rwUnsEzctzRdqYripv2cyjg@mail.gmail.com>
In-Reply-To
<PH7PR07MB9467AD34C96AEE60D5A4369F8C58A@PH7PR07MB9467.namprd07.prod.outlook.com>

On Fri, Jun 16, 2023 at 6:04 PM eric.frederich@siemens.com <eric.frederich@siemens.com> wrote:

Show 6 quoted lines
>
> Thanks for the reply and finding that code.
> I'm wondering a couple of things.
>
> A)
> Is it reasonable to expect that a trailer added during commit with `git commit --trailer some-key:some-value` always be able to be retrieved regardless of the contents of the commit message?
I think the following 3 conditions would be needed:
  - `git commit --trailer ...` should be fixed using a patch like the
one Peff proposed, and the trailer should be added using this fixed
command,
  -  a command that outputs only a commit message, or perhaps commits
headers and the commit message, like `git cat-file commit rev`, should
be used to retrieve the commit message that is passed to `git
interpret-trailers` for retrieving the trailer,
  - and `git interpret-trailers` should be used with both --parse and
--no-divider.
> I am migrating source code history from an older SCM to Git and would like to preserve the change messages.
Have you looked at existing tools to do that (like maybe reposurgeon)?
Show 7 quoted lines
> B)
> Should anything that is retrieved via:
>     `git cat-file commit $SHA | git interpret-trailers --parse`
> also be displayed via:
>    `git log -1 --format="%(trailers:key=some-key,valueonly,separator=%x2c) %H %T" $SHA`
>
> ... why is there a difference?  (Explicit call to interpret-trailers shows the trailer, but the log command does not).
I believe Peff explained that.
> With some minimal investigation (I added a printf at the top of find_patch_start), I noticed that find_patch_start is called during call to `git interpret-trailers` but it is NOT called during call to `git log`.
> This means the same code paths are not being followed in those two cases dealing w/ trailers.
> I would expect that it should use the same code paths in both cases.

The log command shows all the content of the commit message as is, without any parsing. So yeah it doesn't use interpret-trailers' code which is useful for modifying or parsing trailers contained in commit messages.

Previous: eric.frederich@siemens.comNext: Linus Arver
Message 10 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.