mbox series

[0/2] cat-file: support NUL-delimited input with `-z`

Message ID cover.1658532524.git.me@ttaylorr.com (mailing list archive)
Headers show
Series cat-file: support NUL-delimited input with `-z` | expand

Message

Taylor Blau July 22, 2022, 11:28 p.m. UTC
This short patch series implements a `-z` mode that is compatible with
the `--batch`, `--batch-check`, and new `--batch-command` options in
`cat-file`.

This came out of a request from a colleague to support `cat-file`
invocations that refer to a tree entry whose name includes a newline
character.

The implementation is mostly straightforward, though the second patch
(which contains the main substance of this change) has a few additional
thoughts on areas for future cleanup. The first patch is preparatory, but
could easily be squashed, too.

Thanks in advance for your review!

Taylor Blau (2):
  t1006: extract --batch-command inputs to variables
  builtin/cat-file.c: support NUL-delimited input with `-z`

 Documentation/git-cat-file.txt |  7 +++-
 builtin/cat-file.c             | 28 +++++++++++--
 t/t1006-cat-file.sh            | 72 +++++++++++++++++++++++++++-------
 3 files changed, 88 insertions(+), 19 deletions(-)

Comments

Junio C Hamano July 23, 2022, 4:44 a.m. UTC | #1
Taylor Blau <me@ttaylorr.com> writes:

> This short patch series implements a `-z` mode that is compatible with
> the `--batch`, `--batch-check`, and new `--batch-command` options in
> `cat-file`.

It's a shame that we forgot that people use strange "object name"
like "<tree>:<path>", when we originally intended to only take
simple object names, like fully-spelled hexadecimal.  And if we were
prepared to take <path>, we should have make sure we use the usual
cquote convention.