]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/multi-pack-index.c: split sub-commands
authorTaylor Blau <me@ttaylorr.com>
Tue, 30 Mar 2021 15:03:57 +0000 (11:03 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 30 Mar 2021 19:16:56 +0000 (12:16 -0700)
commit60ca94769ce45161c4bcfb4aa92212585d3da0f6
treef33b4feb4c095483ec09147eb20bcb004d97a77a
parentb25b727494f4782c7af1db31fdfde1cc9b30f7c4
builtin/multi-pack-index.c: split sub-commands

Handle sub-commands of the 'git multi-pack-index' builtin (e.g.,
"write", "repack", etc.) separately from one another. This allows
sub-commands with unique options, without forcing cmd_multi_pack_index()
to reject invalid combinations itself.

This comes at the cost of some duplication and boilerplate. Luckily, the
duplication is reduced to a minimum, since common options are shared
among sub-commands due to a suggestion by Ævar. (Sub-commands do have to
retain the common options, too, since this builtin accepts common
options on either side of the sub-command).

Roughly speaking, cmd_multi_pack_index() parses options (including
common ones), and stops at the first non-option, which is the
sub-command. It then dispatches to the appropriate sub-command, which
parses the remaining options (also including common options).

Unknown options are kept by the sub-commands in order to detect their
presence (and complain that too many arguments were given).

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/multi-pack-index.c