fetch-object: set exact_oid when fetching

fetch_objects() currently does not set exact_oid in struct ref when invoking transport_fetch_refs(). If the server supports ref-in-want, fetch_pack() uses this field to determine whether a wanted ref should be requested as a "want-ref" line or a "want" line; without the setting of exact_oid, the wrong line will be sent. Set exact_oid, so that the correct line is sent. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Tan committed Sep 12, 2018 at 08:47 UTC e68302011c902961bc55db5eec9b9e32acd114ca
2 files changed +13
fetch-object.c
+1
@@ -32,6 +32,7 @@ void fetch_objects(const char *remote_name, const struct object_id *oids,
32 for (i = 0; i < oid_nr; i++) {
33 struct ref *new_ref = alloc_ref(oid_to_hex(&oids[i]));
34 oidcpy(&new_ref->old_oid, &oids[i]);
35 + new_ref->exact_oid = 1;
36 new_ref->next = ref;
37 ref = new_ref;
38 }
t/t0410-partial-clone.sh
+12
@@ -170,6 +170,18 @@ test_expect_success 'fetching of missing objects' '
170 git verify-pack --verbose "$IDX" | grep "$HASH"
171 '
172
173 +test_expect_success 'fetching of missing objects works with ref-in-want enabled' '
174 + # ref-in-want requires protocol version 2
175 + git -C server config protocol.version 2 &&
176 + git -C server config uploadpack.allowrefinwant 1 &&
177 + git -C repo config protocol.version 2 &&
178 +
179 + rm -rf repo/.git/objects/* &&
180 + rm -f trace &&
181 + GIT_TRACE_PACKET="$(pwd)/trace" git -C repo cat-file -p "$HASH" &&
182 + grep "git< fetch=.*ref-in-want" trace
183 +'
184 +
185 test_expect_success 'rev-list stops traversal at missing and promised commit' '
186 rm -rf repo &&
187 test_create_repo repo &&