]> git.ipfire.org Git - thirdparty/git.git/commit - t/t1006-cat-file.sh
cat-file: make --batch-all-objects a CMDMODE
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Tue, 28 Dec 2021 13:28:46 +0000 (14:28 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 30 Dec 2021 21:05:29 +0000 (13:05 -0800)
commit485fd2c3dae9c05b43fe237f402274a59eb68e81
treed0dcd9cba0c8ae9e4ee649fe05492ed2f577144c
parent5a40417876c8ec97e1f367a1638a558ec010e3d8
cat-file: make --batch-all-objects a CMDMODE

The usage of OPT_CMDMODE() in "cat-file"[1] was added in parallel with
the development of[3] the --batch-all-objects option[4], so we've
since grown[5] checks that it can't be combined with other command
modes, when it should just be made a top-level command-mode
instead. It doesn't combine with --filters, --textconv etc.

By giving parse_options() information about what options are mutually
exclusive with one another we can get the die() message being removed
here for free, we didn't even use that removed message in some cases,
e.g. for both of:

    --batch-all-objects --textconv
    --batch-all-objects --filters

We'd take the "goto usage" in the "if (opt)" branch, and never reach
the previous message. Now we'll emit e.g.:

    $ git cat-file --batch-all-objects --filters
    error: option `filters' is incompatible with --batch-all-objects

1. b48158ac94c (cat-file: make the options mutually exclusive, 2015-05-03)
2. https://lore.kernel.org/git/xmqqtwspgusf.fsf@gitster.dls.corp.google.com/
3. https://lore.kernel.org/git/20150622104559.GG14475@peff.net/
4. 6a951937ae1 (cat-file: add --batch-all-objects option, 2015-06-22)
5. 321459439e1 (cat-file: support --textconv/--filters in batch mode, 2016-09-09)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/cat-file.c
t/t1006-cat-file.sh