Skip to content

Commit 571cdfd

Browse files
committed
Merge branch 'tr/remote-tighten-commandline-parsing' into maint
* tr/remote-tighten-commandline-parsing: remote: 'show' and 'prune' can take more than one remote remote: check for superfluous arguments in 'git remote add' remote: add a test for extra arguments, according to docs
2 parents 49010c3 + b17dd3f commit 571cdfd

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

Documentation/git-remote.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ SYNOPSIS
1818
'git remote set-url' [--push] <name> <newurl> [<oldurl>]
1919
'git remote set-url --add' [--push] <name> <newurl>
2020
'git remote set-url --delete' [--push] <name> <url>
21-
'git remote' [-v | --verbose] 'show' [-n] <name>
22-
'git remote prune' [-n | --dry-run] <name>
21+
'git remote' [-v | --verbose] 'show' [-n] <name>...
22+
'git remote prune' [-n | --dry-run] <name>...
2323
'git remote' [-v | --verbose] 'update' [-p | --prune] [(<group> | <remote>)...]
2424

2525
DESCRIPTION

builtin/remote.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static int add(int argc, const char **argv)
178178
argc = parse_options(argc, argv, NULL, options, builtin_remote_add_usage,
179179
0);
180180

181-
if (argc < 2)
181+
if (argc != 2)
182182
usage_with_options(builtin_remote_add_usage, options);
183183

184184
if (mirror && master)

t/t5505-remote.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,4 +1003,26 @@ test_expect_success 'remote set-url --delete baz' '
10031003
cmp expect actual
10041004
'
10051005

1006+
test_expect_success 'extra args: setup' '
1007+
# add a dummy origin so that this does not trigger failure
1008+
git remote add origin .
1009+
'
1010+
1011+
test_extra_arg () {
1012+
test_expect_success "extra args: $*" "
1013+
test_must_fail git remote $* bogus_extra_arg 2>actual &&
1014+
grep '^usage:' actual
1015+
"
1016+
}
1017+
1018+
test_extra_arg add nick url
1019+
test_extra_arg rename origin newname
1020+
test_extra_arg remove origin
1021+
test_extra_arg set-head origin master
1022+
# set-branches takes any number of args
1023+
test_extra_arg set-url origin newurl oldurl
1024+
# show takes any number of args
1025+
# prune takes any number of args
1026+
# update takes any number of args
1027+
10061028
test_done

0 commit comments

Comments
 (0)