]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fetch-object: set exact_oid when fetching
authorJonathan Tan <jonathantanmy@google.com>
Wed, 12 Sep 2018 15:47:38 +0000 (08:47 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 13 Sep 2018 20:57:31 +0000 (13:57 -0700)
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>
fetch-object.c
t/t0410-partial-clone.sh

index 1af1bf857a1710289603b8c8139e2ae2d830732d..42665488008bc0fffafa5d4e0455bc22b510b92a 100644 (file)
@@ -32,6 +32,7 @@ void fetch_objects(const char *remote_name, const struct object_id *oids,
        for (i = 0; i < oid_nr; i++) {
                struct ref *new_ref = alloc_ref(oid_to_hex(&oids[i]));
                oidcpy(&new_ref->old_oid, &oids[i]);
+               new_ref->exact_oid = 1;
                new_ref->next = ref;
                ref = new_ref;
        }
index 128130066499feb5bdad705b6fb0ef03bf446fe9..0ab02c337da4d20c9a60cfacc8fc97258b6ab61a 100755 (executable)
@@ -170,6 +170,18 @@ test_expect_success 'fetching of missing objects' '
        git verify-pack --verbose "$IDX" | grep "$HASH"
 '
 
+test_expect_success 'fetching of missing objects works with ref-in-want enabled' '
+       # ref-in-want requires protocol version 2
+       git -C server config protocol.version 2 &&
+       git -C server config uploadpack.allowrefinwant 1 &&
+       git -C repo config protocol.version 2 &&
+
+       rm -rf repo/.git/objects/* &&
+       rm -f trace &&
+       GIT_TRACE_PACKET="$(pwd)/trace" git -C repo cat-file -p "$HASH" &&
+       grep "git< fetch=.*ref-in-want" trace
+'
+
 test_expect_success 'rev-list stops traversal at missing and promised commit' '
        rm -rf repo &&
        test_create_repo repo &&