{"thread":{"id":"35481","subject":"[PATCH] clone,fetch: catch non positive --depth option value","startedAt":"2013-12-05T03:31:11Z","lastAt":"2013-12-05T03:31:11Z","messageCount":1,"participants":["Nguyễn Thái Ngọc Duy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"231570","messageId":"1386214271-16464-1-git-send-email-pclouds@gmail.com","threadId":"35481","inReplyTo":null,"subject":"[PATCH] clone,fetch: catch non positive --depth option value","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2013-12-05T03:31:11Z","receivedAt":"2013-12-05T03:31:11Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Instead of simply ignoring the value passed to --depth option when\nit is zero or negative, catch and report it as an error to let\npeople know that they were using the option incorrectly.\n\nOriginal-patch-by: Andrés G. Aragoneses <knocte@gmail.com>\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n This replaces aa/transport-non-positive-depth-only\n\n builtin/clone.c | 4 ++++\n builtin/fetch.c | 4 ++++\n 2 files changed, 8 insertions(+)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 552f340..535b52f 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -797,6 +797,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \tif (option_local > 0 && !is_local)\n \t\twarning(_(\"--local is ignored\"));\n \n+\t/* no need to be strict, transport_set_option() will validate it again */\n+\tif (option_depth && atoi(option_depth) < 1)\n+\t\tdie(_(\"depth %s is not a positive number\"), option_depth);\n+\n \tif (argc == 2)\n \t\tdir = xstrdup(argv[1]);\n \telse\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 2496ad2..ed399eb 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -1047,6 +1047,10 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)\n \t\t}\n \t}\n \n+\t/* no need to be strict, transport_set_option() will validate it again */\n+\tif (depth && atoi(depth) < 1)\n+\t\tdie(_(\"depth %s is not a positive number\"), depth);\n+\n \tif (recurse_submodules != RECURSE_SUBMODULES_OFF) {\n \t\tif (recurse_submodules_default) {\n \t\t\tint arg = parse_fetch_recurse_submodules_arg(\"--recurse-submodules-default\", recurse_submodules_default);\n-- \n1.8.5.1.25.g8667982\n"}]}