Skip to content

Commit eb86a50

Browse files
michaeledgargitster
authored andcommitted
fetch-pack: check for shallow if depth given
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> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 282616c commit eb86a50

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fetch-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
786786
sort_ref_list(&ref, ref_compare_name);
787787
qsort(sought, nr_sought, sizeof(*sought), cmp_ref_by_name);
788788

789-
if (is_repository_shallow() && !server_supports("shallow"))
789+
if ((args->depth > 0 || is_repository_shallow()) && !server_supports("shallow"))
790790
die("Server does not support shallow clients");
791791
if (server_supports("multi_ack_detailed")) {
792792
if (args->verbose)

0 commit comments

Comments
 (0)