Subject: Re: [PATCH] repo: add -z as an alias for --format=nul to git-repo-structure

From: Junio C Hamano <[email-masked]>
Date: Mon, 01 Dec 2025 19:45:07 -0800

Patrick Steinhardt <[email-masked]> writes:

> I think this ultimately stems from [2], where you argue that it _is_
> possible to say `git repo info --format=table -z`, and the last option
> wins. It's the same for `git repo structure`, so I'd argue we should be
> consistent.

I do not think so; [2] was about the explicit "--format=nul and -z
are incompatible" code.  Even without this '-z" thing, if you have

    [--opt=(a|b|c)]

I _think_ our intention is to allow "git cmd --opt=a --opt=b" from
the user and let the last one win.  If you add "-z",

    [--format=(table|keyvalue|nul)] [-z]
    [--format=(table|keyvalue|nul) | -z]

I think both would mean the same thing; I just was wonering if
grouping them together in one bracket makes it more obvious that
these are all options to control the output format.

There was also an inquiry about writing it like

    [(--format=(table|keyvalue|nul) | -z)]

or even

    [(--format=(table|keyvalue|nul) | -z)...]

as these can be repeated and let the last-one-wins rule decide the
final outcome, but we do not do that.  I thought the final comment
on this was in

https://lore.kernel.org/git/6186055.lOV4Wx5bFT@cayenne/

where the message said

    In fact the correct formatting is:

    [--format=(keyvalue|nul) | -z] [<key>...]

    As stated in "CodingGuidelines:

     Use spacing around "|" token(s), but not immediately after opening or
     before closing a [] or () pair:
       Do: [-q | --quiet]
       Don't: [-q|--quiet]

     Don't use spacing around "|" tokens when they're used to separate the
     alternate arguments of an option:
        Do: --track[=(direct|inherit)]
        Don't: --track[=(direct | inherit)]

and that was where the thread ended, I think.

> [1]: <[email-masked]>
> [2]: <[email-masked]>