Skip to content

Commit d52dc4b

Browse files
jrngitster
authored andcommitted
clone: detect extra arguments
If git clone is given more than two non-option arguments, it silently throws away all but the first one. Complain instead. Discovered by comparing the new builtin clone to the old git-clone.sh. Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ebc9d42 commit d52dc4b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

builtin-clone.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,13 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
379379
argc = parse_options(argc, argv, prefix, builtin_clone_options,
380380
builtin_clone_usage, 0);
381381

382+
if (argc > 2)
383+
usage_msg_opt("Too many arguments.",
384+
builtin_clone_usage, builtin_clone_options);
385+
382386
if (argc == 0)
383-
die("You must specify a repository to clone.");
387+
usage_msg_opt("You must specify a repository to clone.",
388+
builtin_clone_usage, builtin_clone_options);
384389

385390
if (option_mirror)
386391
option_bare = 1;

0 commit comments

Comments
 (0)