Re: [PATCH v4] ls-files: introduce "--format" option
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Jun 27, 2022, 18:34 UTC
- Message-ID
- <220627.86v8smgcx2.gmgdl@evledraar.gmail.com>
- In-Reply-To
- <pull.1262.v4.git.1656257376109.gitgitgadget@gmail.com>
On Sun, Jun 26 2022, ZheNing Hu via GitGitGadget wrote:
Show 20 quoted lines
> From: ZheNing Hu <adlternative@gmail.com> > > Add a new option --format that output index enties > informations with custom format, taking inspiration > from the option with the same name in the `git ls-tree` > command. > > --format cannot used with -s, -o, -k, --resolve-undo, > --deduplicate and --eol. > > Signed-off-by: ZheNing Hu <adlternative@gmail.com> > --- > [...] > +test_expect_success 'git ls-files --format with --debug' ' > + git ls-files --debug >expect && > + git ls-files --format="%(path)" --debug >actual && > + test_cmp expect actual > +' > + > +test_done
I'm not sure what to make of this.
In some ways I think this makes more sense than what I suggested in https://lore.kernel.org/git/220624.86letmi383.gmgdl@evledraar.gmail.com/; but I had to think for a second about what's going on here.
In my version I suggested having this work with --debug, but not in this way, in my version you'd always emit the debug output, and the format output.
But here e.g.:
git ls-files -t --debug
Will emit "H tag.c" or whatever, but if you add --format the -t option is silently discarded.
So the test is relying on "%(path)" being the default format.
I think extending this to e.g. test what happens with "-t" would be a good thing, but also in general does combining --format with -t make sense, and are there other such options where the combination might not make sense?
So I'm not 100% sure, but I think I'd prefer my version, but I see how it would get hairy to support, e.g.:
git ls-files -s --debug --format=...
Should work, but you'd have to special-case the logic for erroring if -s is combined with --format.
Anyway, I think it would be fine to leave this in whatever state is easy, the --debug option "just for debugging".
But re https://lore.kernel.org/git/CAOLTT8Tc95-aUE+uN2d8QjTJpGpGw6cBJfG+bpmyE55OcXTSRA@mail.gmail.com/ I think it might be interesting to get --format to a state where we can remove --debug entirely.
I.e. in c2a29405105 (t1091/t3705: remove 'test-tool read-cache --table', 2021-12-22) we could replace some similar test-only code with "git ls-files". I for one wouldn't mind --debug going away entirely, and have the t3705-add-sparse-checkout.sh tests use --format instead.
Or we could keep --debug, but just have it powerful enough to do what print_debug() is doing now, possibly without "truly internal" stuff like "ce_flags".