Re: [PATCH] clone: check if server supports shallow clones
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 17, 2015, 16:35 UTC
- Message-ID
- <xmqq8ubi47jo.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <20150611143204.GA3343@peff.net>
Jeff King <peff@peff.net> writes:
Show 25 quoted lines
> 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.
>
> Of course it's hard to add to the test suite, since we do not have a way
> of hitting a server that does not understand shallow (I simply fudged
> server_supports() to return false on the client).We've had the "shallow" capability advertised since ed09aef0 (support fetching into a shallow repository, 2006-10-30), and this patch itself may not be that super-important in practice. Let's not worry too much about a test for situations that may not likely matter to us [*1*].
Thanks, all.
[Footnote]
*1* How behind are re-implementations of upload-pack by other people, I have to wonder, though?