summaryrefslogtreecommitdiff
path: root/cache-tree.c
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2021-07-23 18:52:23 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-07-23 21:22:21 (GMT)
commitd3da223f2214ebc1527ccf66428aa975de916682 (patch)
treeaae4dd727ca7149ef83b96b61859891a0c4ccda3 /cache-tree.c
parentb2896d27391afcbc990439e63972bb33693a7d6b (diff)
downloadgit-d3da223f2214ebc1527ccf66428aa975de916682.zip
git-d3da223f2214ebc1527ccf66428aa975de916682.tar.gz
git-d3da223f2214ebc1527ccf66428aa975de916682.tar.bz2
cache-tree: prefetch in partial clone read-tree
"git read-tree" checks the existence of the blobs referenced by the given tree, but does not bulk prefetch them. Add a bulk prefetch. The lack of prefetch here was noticed at $DAYJOB during a merge involving some specific commits, but I couldn't find a minimal merge that didn't also trigger the prefetch in check_updates() in unpack-trees.c (and in all these cases, the lack of prefetch in cache-tree.c didn't matter because all the relevant blobs would have already been prefetched by then). This is why I used read-tree here to exercise this code path. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'cache-tree.c')
-rw-r--r--cache-tree.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/cache-tree.c b/cache-tree.c
index 45e5866..9ba2c7c 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -237,6 +237,11 @@ int cache_tree_fully_valid(struct cache_tree *it)
return 1;
}
+static int must_check_existence(const struct cache_entry *ce)
+{
+ return !(has_promisor_remote() && ce_skip_worktree(ce));
+}
+
static int update_one(struct cache_tree *it,
struct cache_entry **cache,
int entries,
@@ -378,8 +383,7 @@ static int update_one(struct cache_tree *it,
}
ce_missing_ok = mode == S_IFGITLINK || missing_ok ||
- (has_promisor_remote() &&
- ce_skip_worktree(ce));
+ !must_check_existence(ce);
if (is_null_oid(oid) ||
(!ce_missing_ok && !has_object_file(oid))) {
strbuf_release(&buffer);
@@ -466,6 +470,9 @@ int cache_tree_update(struct index_state *istate, int flags)
if (!istate->cache_tree)
istate->cache_tree = cache_tree();
+ if (!(flags & WRITE_TREE_MISSING_OK) && has_promisor_remote())
+ prefetch_cache_entries(istate, must_check_existence);
+
trace_performance_enter();
trace2_region_enter("cache_tree", "update", the_repository);
i = update_one(istate->cache_tree, istate->cache, istate->cache_nr,