git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] clone: check if server supports shallow clones

From
Michael Edgar <adgar@google.com>
Date
Jun 11, 2015, 18:18 UTC
Message-ID
<CALkbG6+vRqKwmBjK9jwSph4iUUbqPjiuNdHEeT3nvFhFJ0VpEg@mail.gmail.com>
In-Reply-To
<20150611143204.GA3343@peff.net>
On Thu, Jun 11, 2015 at 10:32 AM, Jeff King <peff@peff.net> wrote:
Show 21 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.

Great point! Duy's proposed fix worked for me testing against the Git server that led me to the original bug (code.google.com), for both clones and init/fetch.

Shall I send that out as a revised patch for review? (This is my first stab at a Git patch)

> 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).

I noticed this, and figured it would be more dangerous for users to include a testing backdoor (eg a flag overriding the advertised capabilities). Is that an accurate assessment, or is there a safer way to test these sorts of interop cases?

Cheers!
-- 
Michael Edgar | Software Engineer | adgar@google.com
Previous: Jeff KingNext: Junio C Hamano
Message 7 of 12 in “clone: check if server supports shallow clones”
  1. clone: check if server supports shallow clonesMike Edgar, Jun 10, 2015
  2. Jeff KingJun 10, 2015
  3. Michael EdgarJun 10, 2015
  4. Jeff KingJun 10, 2015
  5. Duy NguyenJun 11, 2015
  6. Jeff KingJun 11, 2015
  7. Michael EdgarJun 11, 2015
  8. Junio C HamanoJun 11, 2015
  9. fetch-pack: check for shallow if depth givenMike Edgar, Jun 17, 2015
  10. Jeff KingJun 17, 2015
  11. Junio C HamanoJun 17, 2015
  12. Jeff KingJun 17, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.