Skip to content

Commit 8f9d80f

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0d330a5 commit 8f9d80f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

builtin/remote.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -862,12 +862,14 @@ static int rm(int argc, const char **argv, const char *prefix)
862862
cb_data.skipped = &skipped;
863863
cb_data.keep = &known_remotes;
864864

865-
if (argc != 2)
865+
argc = parse_options(argc, argv, prefix, options,
866+
builtin_remote_rm_usage, 0);
867+
if (argc != 1)
866868
usage_with_options(builtin_remote_rm_usage, options);
867869

868-
remote = remote_get(argv[1]);
870+
remote = remote_get(argv[0]);
869871
if (!remote_is_configured(remote, 1)) {
870-
error(_("No such remote: '%s'"), argv[1]);
872+
error(_("No such remote: '%s'"), argv[0]);
871873
exit(2);
872874
}
873875

0 commit comments

Comments
 (0)