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

From: Patrick Steinhardt <[email-masked]>
Date: Mon, 1 Dec 2025 09:28:47 +0100

On Sun, Nov 30, 2025 at 06:21:21PM -0800, Junio C Hamano wrote:
> Lucas Seiki Oshiro <[email-masked]> writes:
> 
> > -git repo structure [--format=(table|keyvalue|nul)]
> > +git repo structure [--format=(table|keyvalue|nul)] [-z]
> 
> It's a minor thing but I wonder if this should be more like
> 
>     git repo structure [--format=(table|keyvalue|nul) | -z]

This discussion rings a bell -- didn't we already discuss this for `git
repo info`? Yup, indeed [1]. Initial versions of `git repo info `-z`
also had it formatted like the above, but the discussion eventually led
to a version that is the same as the one proposed in this patch here.

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.

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

> > diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh
> > index 36a71a144e..5a50acf345 100755
> > --- a/t/t1901-repo-structure.sh
> > +++ b/t/t1901-repo-structure.sh
> > @@ -101,6 +101,12 @@ test_expect_success 'keyvalue and nul format' '
> >  		tr "\n=" "\0\n" <expect >expect_nul &&
> >  		git repo structure --format=nul >out 2>err &&
> >  
> > +		test_cmp expect_nul out &&
> > +		test_line_count = 0 err &&
> > +
> > +		# Check -z
> > +		git repo structure --format=nul >out 2>err &&
> 
> Didn't you want to check "-z", not "--format=nul"?  In addition,
> perhaps test
> 
> 	# "-z", as a synonym to "--format=nul", participates in the
> 	# usual "last one wins" rule.
> 	git repo structure --format=table -z >out 2>err &&
> 
> as well, or is it too obvious (by knowing how parse-options API is
> used) that it is pointless to test?

I think it wouldn't be pointless given the above -- we should verify
that the last one wins, regardless of whether you use the alias or the
long option.

Patrick