Skip to content

Commit e683020

Browse files
jonathantanmygitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8708ca0 commit e683020

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

fetch-object.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ void fetch_objects(const char *remote_name, const struct object_id *oids,
3232
for (i = 0; i < oid_nr; i++) {
3333
struct ref *new_ref = alloc_ref(oid_to_hex(&oids[i]));
3434
oidcpy(&new_ref->old_oid, &oids[i]);
35+
new_ref->exact_oid = 1;
3536
new_ref->next = ref;
3637
ref = new_ref;
3738
}

t/t0410-partial-clone.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,18 @@ test_expect_success 'fetching of missing objects' '
170170
git verify-pack --verbose "$IDX" | grep "$HASH"
171171
'
172172

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+
173185
test_expect_success 'rev-list stops traversal at missing and promised commit' '
174186
rm -rf repo &&
175187
test_create_repo repo &&

0 commit comments

Comments
 (0)