Re: [PATCH v3 5/5] pretty: add support for separator option in %(trailers)
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Nov 20, 2018, 08:25 UTC
- Message-ID
- <CAPig+cRhnEO7suiCB4j_7c3NdRHWkPjY8mp0jU76KdOoM_hhPQ@mail.gmail.com>
- In-Reply-To
- <20181118114427.1397-6-anders@0x63.nu>
On Sun, Nov 18, 2018 at 6:45 AM Anders Waldenborg <anders@0x63.nu> wrote:
Show 17 quoted lines
> By default trailer lines are terminated by linebreaks ('\n'). By
> specifying the new 'separator' option they will instead be separated by
> user provided string and have separator semantics rather than terminator
> semantics. The separator string can contain the literal formatting codes
> %n and %xNN allowing it to be things that are otherwise hard to type as
> %x00, or comma and end-parenthesis which would break parsing.
>
> Signed-off-by: Anders Waldenborg <anders@0x63.nu>
> ---
> diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
> @@ -218,9 +218,16 @@ endif::git-rev-list[]
> + ** 'separator=<SEP>': specifying an alternative separator than the
> + default line feed character. SEP may can contain the literal
> + formatting codes %n and %xNN allowing it to contain characters
> + that are hard to type such as %x00, or comma and end-parenthesis
> + which would break parsing. If option is given multiple times only
> + the last one is used.It's not clear from this documentation what constitutes a valid <SEP>. Is it restricted to a single character? Can it be an arbitrary string? If a string, does it need to be quoted? Does it support backslash escaping?
Although I was able to guess that %xNN allowed hex input of a 7- or 8-bit value, I found myself wondering what I was supposed to replace 'n' with in "%n". I didn't fathom that "%n" was meant to be typed literally to specify a newline character.
> + ** Examples: `%(trailers:only,unfold,separator=%x00)` unfolds and > + shows all trailer lines separated by NUL character, > + `%(trailers:key=Reviewed-by,unfold)` unfolds and shows trailer > + lines with key `Reviewed-by`.