builtin/remote.c: let parse-options parse subcommands
commitb26a412f1e96e40c419001991486cced837679a6
authorSZEDER Gábor <szeder.dev@gmail.com>
Fri, 19 Aug 2022 16:04:08 +0000 (19 18:04 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 19 Aug 2022 18:13:16 +0000 (19 11:13 -0700)
tree23f58d32b34c70fc13792f3035e86f45b68649fe
parent729b97332b05564133e4039fbab9f694c25097a2
builtin/remote.c: let parse-options parse subcommands

'git remote' parses its subcommands with a long list of if-else if
statements.  parse-options has just learned to parse subcommands, so
let's use that facility instead, with the benefits of shorter code,
handling unknown subcommands, and listing subcommands for Bash
completion.  Make sure that the default operation mode doesn't accept
any arguments; and while at it remove the capitalization of the error
message and adjust the test checking it accordingly.

Note that 'git remote' has both 'remove' and 'rm' subcommands, and the
former is preferred [1], so hide the latter for completion.

Note also that the functions implementing each subcommand only accept
the 'argc' and '**argv' parameters, so add a (unused) '*prefix'
parameter to make them match the type expected by parse-options, and
thus avoid casting a bunch of function pointers.

[1] e17dba8fe1 (remote: prefer subcommand name 'remove' to 'rm',
    2012-09-06)

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/remote.c
t/t5505-remote.sh