* [PATCH v2] fetch-pack: check for shallow if depth given
@ 2015-06-18 0:31 Mike Edgar
0 siblings, 0 replies; 3+ messages in thread
From: Mike Edgar @ 2015-06-18 0:31 UTC (permalink / raw)
To: gitster; +Cc: git, Mike Edgar
When a repository is first fetched as a shallow clone, either by
git-clone or by fetching into an empty repo, the server's capabilities
are not currently consulted. The client will send shallow requests even
if the server does not understand them, and the resulting error may be
unhelpful to the user. This change pre-emptively checks so we can exit
with a helpful error if necessary.
Signed-off-by: Mike Edgar <adgar@google.com>
Acked-by: Jeff King <peff@peff.net>
---
fetch-pack.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fetch-pack.c b/fetch-pack.c
index 48526aa..849a9d6 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -790,7 +790,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
sort_ref_list(&ref, ref_compare_name);
qsort(sought, nr_sought, sizeof(*sought), cmp_ref_by_name);
- if (is_repository_shallow() && !server_supports("shallow"))
+ if ((args->depth > 0 || is_repository_shallow()) && !server_supports("shallow"))
die("Server does not support shallow clients");
if (server_supports("multi_ack_detailed")) {
if (args->verbose)
--
2.4.3.573.g4eafbef
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] clone: check if server supports shallow clones
@ 2015-06-11 20:44 Junio C Hamano
2015-06-17 11:48 ` [PATCH v2] fetch-pack: check for shallow if depth given Mike Edgar
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2015-06-11 20:44 UTC (permalink / raw)
To: Michael Edgar; +Cc: Jeff King, Duy Nguyen, Git Mailing List
Michael Edgar <adgar@google.com> writes:
> On Thu, Jun 11, 2015 at 10:32 AM, Jeff King <peff@peff.net> wrote:
>> On Thu, Jun 11, 2015 at 08:02:33PM +0700, Duy Nguyen wrote:
>>
>>> > I see that do_fetch_pack checks server_supports("shallow"). Is that
>>> > enough to cover all fetch cases? And if it is, why does it not cover the
>>> > matching clone cases?
>>>
>>> I think this replacement check would do
>>>
>>> if ((args->depth > 0 || is_repository_shallow()) && !server_supports("shallow"))
>>> die("Server does not support shallow clients");
>>
>> Oh, indeed, there is the depth flag I was looking for. :)
>>
>> And from some rudimentary testing, I believe that:
>>
>> git init
>> git fetch --depth=1 ...
>>
>> is currently broken in the same way as clone (we are not shallow yet, so
>> it does not complain when the server does not support it). I think the
>> patch above fixes both that and the clone case.
>
> Shall I send that out as a revised patch for review? (This is my first
> stab at a Git
> patch)
Surely, and thanks. Hopefully one or both of them will Ack it and
all there is left for me to do will be to pick it up ;-)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] fetch-pack: check for shallow if depth given
2015-06-11 20:44 [PATCH] clone: check if server supports shallow clones Junio C Hamano
@ 2015-06-17 11:48 ` Mike Edgar
2015-06-17 17:00 ` Jeff King
0 siblings, 1 reply; 3+ messages in thread
From: Mike Edgar @ 2015-06-17 11:48 UTC (permalink / raw)
To: git; +Cc: peff, pclouds, Mike Edgar
When a repository is first fetched as a shallow clone, either by
git-clone or by fetching into an empty repo, the server's capabilities
are not currently consulted. The client will send shallow requests even
if the server does not understand them, and the resulting error may be
unhelpful to the user. This change pre-emptively checks so we can exit
with a helpful error if necessary.
Signed-off-by: Mike Edgar <adgar@google.com>
---
fetch-pack.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fetch-pack.c b/fetch-pack.c
index a912935..a136772 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -809,7 +809,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
sort_ref_list(&ref, ref_compare_name);
qsort(sought, nr_sought, sizeof(*sought), cmp_ref_by_name);
- if (is_repository_shallow() && !server_supports("shallow"))
+ if ((args->depth > 0 || is_repository_shallow()) && !server_supports("shallow"))
die("Server does not support shallow clients");
if (server_supports("multi_ack_detailed")) {
if (args->verbose)
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] fetch-pack: check for shallow if depth given
2015-06-17 11:48 ` [PATCH v2] fetch-pack: check for shallow if depth given Mike Edgar
@ 2015-06-17 17:00 ` Jeff King
0 siblings, 0 replies; 3+ messages in thread
From: Jeff King @ 2015-06-17 17:00 UTC (permalink / raw)
To: Mike Edgar; +Cc: git, pclouds
On Wed, Jun 17, 2015 at 07:48:14AM -0400, Mike Edgar wrote:
> When a repository is first fetched as a shallow clone, either by
> git-clone or by fetching into an empty repo, the server's capabilities
> are not currently consulted. The client will send shallow requests even
> if the server does not understand them, and the resulting error may be
> unhelpful to the user. This change pre-emptively checks so we can exit
> with a helpful error if necessary.
>
> Signed-off-by: Mike Edgar <adgar@google.com>
Looks good to me.
-Peff
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-06-18 0:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-18 0:31 [PATCH v2] fetch-pack: check for shallow if depth given Mike Edgar
-- strict thread matches above, loose matches on Subject: below --
2015-06-11 20:44 [PATCH] clone: check if server supports shallow clones Junio C Hamano
2015-06-17 11:48 ` [PATCH v2] fetch-pack: check for shallow if depth given Mike Edgar
2015-06-17 17:00 ` Jeff King
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 NNTP newsgroup(s).