Merge branch 'nd/transport-positive-depth-only' into maint
authorJunio C Hamano <gitster@pobox.com>
Wed, 5 Feb 2014 21:58:51 +0000 (13:58 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 5 Feb 2014 21:58:52 +0000 (13:58 -0800)
"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

builtin/clone.c
builtin/fetch.c
index 874e0fd0b6e3ea4882783c0b2377016d93bd989d..cc11104d4267f61aa5a2aa5472a5c69c1ccd8994 100644 (file)
@@ -796,6 +796,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
        if (option_local > 0 && !is_local)
                warning(_("--local is ignored"));
 
+       /* no need to be strict, transport_set_option() will validate it again */
+       if (option_depth && atoi(option_depth) < 1)
+               die(_("depth %s is not a positive number"), option_depth);
+
        if (argc == 2)
                dir = xstrdup(argv[1]);
        else
index bd7a10164f4fed8aeb6e8148e2ae8c0a793e7ee0..5bd00d064a7fbfb828f7a7c5e79f8ed0a5a1e959 100644 (file)
@@ -1075,6 +1075,10 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
                }
        }
 
+       /* no need to be strict, transport_set_option() will validate it again */
+       if (depth && atoi(depth) < 1)
+               die(_("depth %s is not a positive number"), depth);
+
        if (recurse_submodules != RECURSE_SUBMODULES_OFF) {
                if (recurse_submodules_default) {
                        int arg = parse_fetch_recurse_submodules_arg("--recurse-submodules-default", recurse_submodules_default);