On Sun, Dec 23, 2018 at 02:41:20PM -0800, William Chargin wrote:
> 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