summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-09-24 10:30:52 -0700
committerJunio C Hamano <gitster@pobox.com>2018-09-24 10:30:52 -0700
commitee99ba7afbbe1c13b10e27f5f9d162f691682146 (patch)
treecedb1c3eba5f357d1479d4a99db260394e555e69
parent4af130af0cfcb88c82eb223d964d4aa94d1d55d5 (diff)
parente68302011c902961bc55db5eec9b9e32acd114ca (diff)
downloadgit-ee99ba7afbbe1c13b10e27f5f9d162f691682146.tar.gz
Merge branch 'jt/lazy-object-fetch-fix'
The code to backfill objects in lazily cloned repository did not work correctly, which has been corrected. * jt/lazy-object-fetch-fix: fetch-object: set exact_oid when fetching fetch-object: unify fetch_object[s] functions
-rw-r--r--fetch-object.c17
-rw-r--r--fetch-object.h8
-rw-r--r--sha1-file.c2
-rwxr-xr-xt/t0410-partial-clone.sh12
-rw-r--r--unpack-trees.c2
5 files changed, 22 insertions, 19 deletions
diff --git a/fetch-object.c b/fetch-object.c
index 853624f811..4266548800 100644
--- a/fetch-object.c
+++ b/fetch-object.c
@@ -23,21 +23,16 @@ static void fetch_refs(const char *remote_name, struct ref *ref)
fetch_if_missing = original_fetch_if_missing;
}
-void fetch_object(const char *remote_name, const unsigned char *sha1)
-{
- struct ref *ref = alloc_ref(sha1_to_hex(sha1));
- hashcpy(ref->old_oid.hash, sha1);
- fetch_refs(remote_name, ref);
-}
-
-void fetch_objects(const char *remote_name, const struct oid_array *to_fetch)
+void fetch_objects(const char *remote_name, const struct object_id *oids,
+ int oid_nr)
{
struct ref *ref = NULL;
int i;
- for (i = 0; i < to_fetch->nr; i++) {
- struct ref *new_ref = alloc_ref(oid_to_hex(&to_fetch->oid[i]));
- oidcpy(&new_ref->old_oid, &to_fetch->oid[i]);
+ 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;
}
diff --git a/fetch-object.h b/fetch-object.h
index 4b269d07ed..d2f996d4e8 100644
--- a/fetch-object.h
+++ b/fetch-object.h
@@ -1,11 +1,7 @@
#ifndef FETCH_OBJECT_H
#define FETCH_OBJECT_H
-#include "sha1-array.h"
-
-extern void fetch_object(const char *remote_name, const unsigned char *sha1);
-
-extern void fetch_objects(const char *remote_name,
- const struct oid_array *to_fetch);
+void fetch_objects(const char *remote_name, const struct object_id *oids,
+ int oid_nr);
#endif
diff --git a/sha1-file.c b/sha1-file.c
index d85f4e93e1..a4367b8f04 100644
--- a/sha1-file.c
+++ b/sha1-file.c
@@ -1317,7 +1317,7 @@ int oid_object_info_extended(struct repository *r, const struct object_id *oid,
* TODO Pass a repository struct through fetch_object,
* such that arbitrary repositories work.
*/
- fetch_object(repository_format_partial_clone, real->hash);
+ fetch_objects(repository_format_partial_clone, real, 1);
already_retried = 1;
continue;
}
diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh
index b35bc89f1e..cfd0655ea1 100755
--- a/t/t0410-partial-clone.sh
+++ b/t/t0410-partial-clone.sh
@@ -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 &&
diff --git a/unpack-trees.c b/unpack-trees.c
index 65f157b9de..51bfac6aa0 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -436,7 +436,7 @@ static int check_updates(struct unpack_trees_options *o)
}
if (to_fetch.nr)
fetch_objects(repository_format_partial_clone,
- &to_fetch);
+ to_fetch.oid, to_fetch.nr);
fetch_if_missing = fetch_if_missing_store;
oid_array_clear(&to_fetch);
}