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

Re: Parsing trailers

From
Jeff King <peff@peff.net>
Date
Jan 3, 2019, 07:07 UTC
Message-ID
<20190103070744.GA24149@sigill.intra.peff.net>
In-Reply-To
<CAFW+GMDazFSDzBrvzMqaPGwew=+CP7tw7G5FfDqcAUYd3qjPuQ@mail.gmail.com>
On Sun, Dec 23, 2018 at 02:41:20PM -0800, William Chargin wrote:
Show 7 quoted lines
> I'm interested in parsing the output of `git-interpret-trailers` in a
> script. I had hoped that the `--parse` option would make this easy, but
> it seems that the `trailer.separators` configuration option is used to
> specify both the input format (which separators may indicate a trailer)
> and the output format of `git interpret-trailers --parse`. Given that
> `trailer.separators` may contain any (non-NUL) characters, including
> whitespace, parsing the output is not straightforward.

IMHO this is a bug in --parse. It was always meant to give sane, normalized output, that you could parse with something like:

  [^:]+: .*

That's what "%(trailers:only)" does (even if the original separator was something else). It also trims any extra whitespace.

So I think it would be reasonable to:
  1. Add an --output-separator option. This should be uncontroversial.
  2. Make --parse imply "--output-separator=:". This might be more
     controversial, because it does change the output. But as I said
     above, I consider the current behavior to simply be a bug.
  3. (Optional) Add a "-z" option which uses "\0" both
     within and between trailer records. This obviously solves your
     problem without steps 1 and 2, but I think we should have a way to
     do it without relying on NULs, since they're harder to work with in
     some tools.
-Peff
Previous: William CharginNext: William Chargin
Message 6 of 8 in “Parsing trailers”
  1. William CharginDec 23, 2018
  2. Christian CouderDec 24, 2018
  3. William CharginDec 24, 2018
  4. Christian CouderDec 26, 2018
  5. William CharginDec 26, 2018
  6. Jeff KingJan 3, 2019
  7. William CharginJan 3, 2019
  8. Jeff KingJan 3, 2019

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.