Skip to content

Commit 5594bca

Browse files
pcloudsgitster
authored andcommitted
clone,fetch: catch non positive --depth option value
Instead of simply ignoring the value passed to --depth option when it is zero or negative, catch and report it as an error to let people know that they were using the option incorrectly. Original-patch-by: Andrés G. Aragoneses <[email protected]> Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2f93541 commit 5594bca

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

builtin/clone.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
797797
if (option_local > 0 && !is_local)
798798
warning(_("--local is ignored"));
799799

800+
/* no need to be strict, transport_set_option() will validate it again */
801+
if (option_depth && atoi(option_depth) < 1)
802+
die(_("depth %s is not a positive number"), option_depth);
803+
800804
if (argc == 2)
801805
dir = xstrdup(argv[1]);
802806
else

builtin/fetch.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,10 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
10451045
}
10461046
}
10471047

1048+
/* no need to be strict, transport_set_option() will validate it again */
1049+
if (depth && atoi(depth) < 1)
1050+
die(_("depth %s is not a positive number"), depth);
1051+
10481052
if (recurse_submodules != RECURSE_SUBMODULES_OFF) {
10491053
if (recurse_submodules_default) {
10501054
int arg = parse_fetch_recurse_submodules_arg("--recurse-submodules-default", recurse_submodules_default);

0 commit comments

Comments
 (0)