summaryrefslogtreecommitdiff
path: root/fetch-pack.c
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2019-03-26 12:31:20 -0700
committerJunio C Hamano <gitster@pobox.com>2019-04-01 15:35:54 +0900
commit1e7d440b0a07ec8e71c107d0950ed1dc43b4d20c (patch)
treee6ece4073a5a0029860d33d740a3f84ae7311c9a /fetch-pack.c
parenta51423bc68a11560519d275885122ed61cf7b041 (diff)
downloadgit-1e7d440b0a07ec8e71c107d0950ed1dc43b4d20c.tar.gz
fetch-pack: call prepare_shallow_info only if v0
In fetch_pack(), be clearer that there is no shallow information before the fetch when v2 is used - memset the struct shallow_info to 0 instead of calling prepare_shallow_info(). This patch is in preparation for a future patch in which a v2 fetch might call prepare_shallow_info() after shallow info has been retrieved during the fetch, so I needed to ensure that prepare_shallow_info() is not called before the fetch. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fetch-pack.c')
-rw-r--r--fetch-pack.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/fetch-pack.c b/fetch-pack.c
index e69993b2eb..ebb24ada24 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -1648,13 +1648,17 @@ struct ref *fetch_pack(struct fetch_pack_args *args,
packet_flush(fd[1]);
die(_("no matching remote head"));
}
- prepare_shallow_info(&si, shallow);
- if (version == protocol_v2)
+ if (version == protocol_v2) {
+ if (shallow->nr)
+ BUG("Protocol V2 does not provide shallows at this point in the fetch");
+ memset(&si, 0, sizeof(si));
ref_cpy = do_fetch_pack_v2(args, fd, ref, sought, nr_sought,
pack_lockfile);
- else
+ } else {
+ prepare_shallow_info(&si, shallow);
ref_cpy = do_fetch_pack(args, fd, ref, sought, nr_sought,
&si, pack_lockfile);
+ }
reprepare_packed_git(the_repository);
if (!args->cloning && args->deepen) {