summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--object-store.h6
-rw-r--r--sha1-file.c3
-rw-r--r--unpack-trees.c17
3 files changed, 17 insertions, 9 deletions
diff --git a/object-store.h b/object-store.h
index 14fc935..dd3f9b7 100644
--- a/object-store.h
+++ b/object-store.h
@@ -280,6 +280,12 @@ struct object_info {
#define OBJECT_INFO_QUICK 8
/* Do not check loose object */
#define OBJECT_INFO_IGNORE_LOOSE 16
+/*
+ * Do not attempt to fetch the object if missing (even if fetch_is_missing is
+ * nonzero). This is meant for bulk prefetching of missing blobs in a partial
+ * clone. Implies OBJECT_INFO_QUICK.
+ */
+#define OBJECT_INFO_FOR_PREFETCH (32 + OBJECT_INFO_QUICK)
int oid_object_info_extended(struct repository *r,
const struct object_id *,
diff --git a/sha1-file.c b/sha1-file.c
index 494606f..ad02649 100644
--- a/sha1-file.c
+++ b/sha1-file.c
@@ -1370,7 +1370,8 @@ int oid_object_info_extended(struct repository *r, const struct object_id *oid,
/* Check if it is a missing object */
if (fetch_if_missing && repository_format_partial_clone &&
- !already_retried && r == the_repository) {
+ !already_retried && r == the_repository &&
+ !(flags & OBJECT_INFO_FOR_PREFETCH)) {
/*
* TODO Investigate having fetch_object() return
* TODO error/success and stopping the music here.
diff --git a/unpack-trees.c b/unpack-trees.c
index 22c41a3..381b0cd 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -404,20 +404,21 @@ static int check_updates(struct unpack_trees_options *o)
* below.
*/
struct oid_array to_fetch = OID_ARRAY_INIT;
- int fetch_if_missing_store = fetch_if_missing;
- fetch_if_missing = 0;
for (i = 0; i < index->cache_nr; i++) {
struct cache_entry *ce = index->cache[i];
- if ((ce->ce_flags & CE_UPDATE) &&
- !S_ISGITLINK(ce->ce_mode)) {
- if (!has_object_file(&ce->oid))
- oid_array_append(&to_fetch, &ce->oid);
- }
+
+ if (!(ce->ce_flags & CE_UPDATE) ||
+ S_ISGITLINK(ce->ce_mode))
+ continue;
+ if (!oid_object_info_extended(the_repository, &ce->oid,
+ NULL,
+ OBJECT_INFO_FOR_PREFETCH))
+ continue;
+ oid_array_append(&to_fetch, &ce->oid);
}
if (to_fetch.nr)
fetch_objects(repository_format_partial_clone,
to_fetch.oid, to_fetch.nr);
- fetch_if_missing = fetch_if_missing_store;
oid_array_clear(&to_fetch);
}
for (i = 0; i < index->cache_nr; i++) {