summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Edgar <adgar@google.com>2015-06-17 07:48:14 -0400
committerJunio C Hamano <gitster@pobox.com>2015-06-17 12:03:58 -0700
commiteb86a507a150b8fbb34fb4e59bf9edbefbbad778 (patch)
tree0f3e81cc8eb23f01ab191b1447fe90e5c15cba07
parent282616c72d1d08a77ca4fe1186cb708c38408d87 (diff)
downloadgit-me/fetch-into-shallow-safety.tar.gz
fetch-pack: check for shallow if depth givenme/fetch-into-shallow-safety
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>
-rw-r--r--fetch-pack.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fetch-pack.c b/fetch-pack.c
index eeee2bb7e0..e3f4ef2c7a 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -786,7 +786,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)