From: Jeff King Date: Thu, 25 Aug 2022 10:51:40 +0000 (-0400) Subject: remote: run "remote rm" argv through parse_options() X-Git-Tag: v2.38.0-rc0~42^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8f9d80f6c06369b563c76ec46c462e740a1a2cf0;p=thirdparty%2Fgit.git remote: run "remote rm" argv through parse_options() The "git remote rm" command's option parsing is fairly primitive: it insists on a single argument, which it treats as the remote name, and displays a usage message otherwise. This is OK, and maybe even convenient, as you could run: git remote rm --foo to drop a remote named "--foo". But it's also weirdly unlike most of the rest of Git, which would complain that there is no option "--foo". The right way to spell it by our conventions is: git remote rm -- --foo but this doesn't currently work. So let's bring the command in line with the rest of Git (including its sibling subcommands!) by feeding argv to parse_options(). We already have an empty options array for the usage helper. Note that we have to adjust the argc index down by one, as parse_options() eats the program name from the start of the array. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- diff --git a/builtin/remote.c b/builtin/remote.c index 96f562f00a..9aff864fd6 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -862,12 +862,14 @@ static int rm(int argc, const char **argv, const char *prefix) cb_data.skipped = &skipped; cb_data.keep = &known_remotes; - if (argc != 2) + argc = parse_options(argc, argv, prefix, options, + builtin_remote_rm_usage, 0); + if (argc != 1) usage_with_options(builtin_remote_rm_usage, options); - remote = remote_get(argv[1]); + remote = remote_get(argv[0]); if (!remote_is_configured(remote, 1)) { - error(_("No such remote: '%s'"), argv[1]); + error(_("No such remote: '%s'"), argv[0]); exit(2); }