Re: [PATCH v9 8/9] ls-tree.c: introduce "--format" option
- From
- Martin Ågren <martin.agren@gmail.com>
- Date
- Jan 10, 2022, 19:41 UTC
- Message-ID
- <CAN0heSoTRpymQh0w2pfJcy+16nTHa6MwY+BAqkvfAmQsnj2ihg@mail.gmail.com>
- In-Reply-To
- <7df58483a4f665f9f54b92a97a6b57704f1e7a0d.1641440700.git.dyroneteng@gmail.com>
Hi Teng,
On Fri, 7 Jan 2022 at 06:34, Teng Long <dyroneteng@gmail.com> wrote:
> +--format=<format>:: > + A string that interpolates `%(fieldname)` from the result > + being shown. It also interpolates `%%` to `%`, and > + `%xx` where `xx`are hex digits interpolates to character
Above, there is a missing space just before "are". That causes the manpage to render a little bit funny.
Show 6 quoted lines
> + with hex code `xx`; for example `%00` interpolates to > + `\0` (NUL), `%09` to `\t` (TAB) and `%0a` to `\n` (LF). > + When specified, `--format` cannot be combined with other > + format-altering options, including `--long`, `--name-only` > + and `--object-only`. > +
> +Customized format: > + > +It's support to print customized format by `%(fieldname)` with `--format` option.
I had to re-read this to understand. How about the following?
It is possible to print in a custom format by using the `--format`
option, which is able to interpolate different fields using a
`%(fieldname)` notation.Just a suggestion. Feel free to tweak or ignore. :-)
Show 9 quoted lines
> +For example, if you want to only print the <object> and <file> fields with a
> +JSON style, executing with a specific "--format" like
> +
> + git ls-tree --format='{"object":"%(object)", "file":"%(file)"}' <tree-ish>
> +
> +The output format changes to:
> +
> + {"object":"<object>", "file":"<file>"}
> +Nice!
Martin