git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org, a.krey@gmx.de
Subject: Re: [PATCH] upload-pack: reject shallow requests that would return nothing
Date: Mon, 28 May 2018 14:55:55 +0900	[thread overview]
Message-ID: <xmqqy3g4jpck.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20180526113518.22403-1-pclouds@gmail.com> ("Nguyễn Thái Ngọc Duy"'s message of "Sat, 26 May 2018 13:35:18 +0200")

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> To avoid this, if rev-list returns nothing, we abort the clone/fetch.
> The user could adjust their request (e.g. --shallow-since further back
> in the past) and retry.

Yeah, that makes sense.

> Another possible option for this case is to fall back to a default
> depth (like depth 1). But I don't like too much magic that way because
> we may return something unexpected to the user.

I agree that it would be a horrible fallback.  I actually am
wondering if we should just silently return no objects without even
telling the user there is something unexpected happening.  After
all, the user may well be expecting with --shallow-since that is too
recent that the fetch may not result in pulling anything new, and
giving a "die" message, which now needs to be distinguished from
other forms of die's like network connectivity or auth failures, is
not all that helpful.

> Note that we need to die() in get_shallow_commits_by_rev_list()
> instead of just checking for empty result from its caller
> deepen_by_rev_list() and handling the error there. The reason is,
> empty result could be a valid case: if you have commits in year 2013
> and you request --shallow-since=year.2000 then you should get a full
> clone (i.e. empty result).

Yup, that latter example makes me more convinced that it also is a
valid outcome if we end up requesting "no" object when shallow-since
names too recent date, e.g. against a project that is dormant since
2013 with --shallow-since=2018/01/01 or something like that, instead
of dying.

> Reported-by: Andreas Krey <a.krey@gmx.de>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  shallow.c             |  3 +++
>  t/t5500-fetch-pack.sh | 11 +++++++++++
>  2 files changed, 14 insertions(+)
>
> diff --git a/shallow.c b/shallow.c
> index df4d44ea7a..44fdca1ace 100644
> --- a/shallow.c
> +++ b/shallow.c
> @@ -175,6 +175,9 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,
>  		die("revision walk setup failed");
>  	traverse_commit_list(&revs, show_commit, NULL, &not_shallow_list);
>  
> +	if (!not_shallow_list)
> +		die("no commits selected for shallow requests");
> +
>  	/* Mark all reachable commits as NOT_SHALLOW */
>  	for (p = not_shallow_list; p; p = p->next)
>  		p->item->object.flags |= not_shallow_flag;
> diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
> index 0680dec808..c8f2d38a58 100755
> --- a/t/t5500-fetch-pack.sh
> +++ b/t/t5500-fetch-pack.sh
> @@ -711,6 +711,17 @@ test_expect_success 'fetch shallow since ...' '
>  	test_cmp expected actual
>  '
>  
> +test_expect_success 'clone shallow since selects no commits' '
> +	test_create_repo shallow-since-the-future &&
> +	(
> +	cd shallow-since-the-future &&
> +	GIT_COMMITTER_DATE="100000000 +0700" git commit --allow-empty -m one &&
> +	GIT_COMMITTER_DATE="200000000 +0700" git commit --allow-empty -m two &&
> +	GIT_COMMITTER_DATE="300000000 +0700" git commit --allow-empty -m three &&
> +	test_must_fail git clone --shallow-since "900000000 +0700" "file://$(pwd)/." ../shallow111
> +	)
> +'
> +
>  test_expect_success 'shallow clone exclude tag two' '
>  	test_create_repo shallow-exclude &&
>  	(

  reply	other threads:[~2018-05-28  5:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-22 19:48 bug: --shallow-since misbehaves on old branch heads Andreas Krey
2018-05-23 16:02 ` Duy Nguyen
2018-05-26 11:35 ` [PATCH] upload-pack: reject shallow requests that would return nothing Nguyễn Thái Ngọc Duy
2018-05-28  5:55   ` Junio C Hamano [this message]
2018-05-28 18:48     ` Duy Nguyen
2018-06-02  6:06       ` Duy Nguyen
2018-06-04 10:46   ` Junio C Hamano
2018-06-04 14:44     ` Duy Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqy3g4jpck.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=a.krey@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).