From: Martin Ă…gren Date: Mon, 10 Jan 2022 19:41:28 GMT Subject: Re: [PATCH v9 8/9] ls-tree.c: introduce "--format" option Message-ID: In-Reply-To: <7df58483a4f665f9f54b92a97a6b57704f1e7a0d.1641440700.git.dyroneteng@gmail.com> Hi Teng, On Fri, 7 Jan 2022 at 06:34, Teng Long wrote: > +--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. > + 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. :-) > +For example, if you want to only print the and fields with a > +JSON style, executing with a specific "--format" like > + > + git ls-tree --format='{"object":"%(object)", "file":"%(file)"}' > + > +The output format changes to: > + > + {"object":"", "file":""} > + Nice! Martin