Re: [PATCH] add warning for depth=0 in git clone.
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Jan 9, 2013, 00:57 UTC
- Message-ID
- <CACsJy8BLLTWd+cTBj1jNW=ODPy7=Kg4-TPUdZ82YCE-0RQpMZA@mail.gmail.com>
- In-Reply-To
- <1357632422-5686-1-git-send-email-stefanbeller@googlemail.com>
On Tue, Jan 8, 2013 at 3:07 PM, Stefan Beller <stefanbeller@googlemail.com> wrote:
Show 15 quoted lines
> ---
> builtin/clone.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/builtin/clone.c b/builtin/clone.c
> index ec2f75b..5e91c1e 100644
> --- a/builtin/clone.c
> +++ b/builtin/clone.c
> @@ -818,6 +818,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
> remote = remote_get(option_origin);
> transport = transport_get(remote, remote->url[0]);
>
> + if (option_depth && transport->smart_options->depth < 1)
> + die(_("--depth less or equal 0 makes no sense; read manpage."));
> +Isn't this too early for the check? The following code is
> if (!is_local) {
> if (!transport->get_refs_list || !transport->fetch)
> die(_("Don't know how to clone %s"), transport->url);transport_set_option(transport, TRANS_OPT_KEEP, "yes");
if (option_depth) transport_set_option(transport, TRANS_OPT_DEPTH, option_depth);
where transport_set_option() calls set_git_option() to initialize transport->smart_options->depth. A check should be done after this point.
-- Duy