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>
This commit is contained in:
parent
a51423bc68
commit
1e7d440b0a
4
commit.h
4
commit.h
@ -257,6 +257,10 @@ extern void setup_alternate_shallow(struct lock_file *shallow_lock,
|
|||||||
extern const char *setup_temporary_shallow(const struct oid_array *extra);
|
extern const char *setup_temporary_shallow(const struct oid_array *extra);
|
||||||
extern void advertise_shallow_grafts(int);
|
extern void advertise_shallow_grafts(int);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize with prepare_shallow_info() or zero-initialize (equivalent to
|
||||||
|
* prepare_shallow_info with a NULL oid_array).
|
||||||
|
*/
|
||||||
struct shallow_info {
|
struct shallow_info {
|
||||||
struct oid_array *shallow;
|
struct oid_array *shallow;
|
||||||
int *ours, nr_ours;
|
int *ours, nr_ours;
|
||||||
|
10
fetch-pack.c
10
fetch-pack.c
@ -1648,13 +1648,17 @@ struct ref *fetch_pack(struct fetch_pack_args *args,
|
|||||||
packet_flush(fd[1]);
|
packet_flush(fd[1]);
|
||||||
die(_("no matching remote head"));
|
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,
|
ref_cpy = do_fetch_pack_v2(args, fd, ref, sought, nr_sought,
|
||||||
pack_lockfile);
|
pack_lockfile);
|
||||||
else
|
} else {
|
||||||
|
prepare_shallow_info(&si, shallow);
|
||||||
ref_cpy = do_fetch_pack(args, fd, ref, sought, nr_sought,
|
ref_cpy = do_fetch_pack(args, fd, ref, sought, nr_sought,
|
||||||
&si, pack_lockfile);
|
&si, pack_lockfile);
|
||||||
|
}
|
||||||
reprepare_packed_git(the_repository);
|
reprepare_packed_git(the_repository);
|
||||||
|
|
||||||
if (!args->cloning && args->deepen) {
|
if (!args->cloning && args->deepen) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user