Skip to content

Commit bf03d6e

Browse files
committed
Merge branch 'nd/transport-positive-depth-only' into maint
"git fetch --depth=0" was a no-op, and was silently ignored. Diagnose it as an error. * nd/transport-positive-depth-only: clone,fetch: catch non positive --depth option value
2 parents ac93028 + 5594bca commit bf03d6e

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
@@ -796,6 +796,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
796796
if (option_local > 0 && !is_local)
797797
warning(_("--local is ignored"));
798798

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

builtin/fetch.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,10 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
10751075
}
10761076
}
10771077

1078+
/* no need to be strict, transport_set_option() will validate it again */
1079+
if (depth && atoi(depth) < 1)
1080+
die(_("depth %s is not a positive number"), depth);
1081+
10781082
if (recurse_submodules != RECURSE_SUBMODULES_OFF) {
10791083
if (recurse_submodules_default) {
10801084
int arg = parse_fetch_recurse_submodules_arg("--recurse-submodules-default", recurse_submodules_default);

0 commit comments

Comments
 (0)