diff options
author | Han Xin <hanxin.hx@bytedance.com> | 2022-07-01 09:34:30 +0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-06-30 23:00:32 -0700 |
commit | 3a1ea94a491e3e0bcbc2d55b4cfb0b9eacace608 (patch) | |
tree | 00b748d6bb087da26ebc381535f9ac87691d1bf4 /commit-graph.c | |
parent | dc8c8deaa6b5847733bd7df011a4c7b7d1a64e0a (diff) | |
download | git-3a1ea94a491e3e0bcbc2d55b4cfb0b9eacace608.tar.gz |
commit-graph.c: no lazy fetch in lookup_commit_in_graph()
The commit-graph is used to opportunistically optimize accesses to
certain pieces of information on commit objects, and
lookup_commit_in_graph() tries to say "no" when the requested commit
does not locally exist by returning NULL, in which case the caller
can ask for (which may result in on-demand fetching from a promisor
remote) and parse the commit object itself.
However, it uses a wrong helper, repo_has_object_file(), to do so.
This helper not only checks if an object is mmediately available in
the local object store, but also tries to fetch from a promisor remote.
But the fetch machinery calls lookup_commit_in_graph(), thus causing an
infinite loop.
We should make lookup_commit_in_graph() expect that a commit given to it
can be legitimately missing from the local object store, by using the
has_object_file() helper instead.
Signed-off-by: Han Xin <hanxin.hx@bytedance.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-graph.c')
-rw-r--r-- | commit-graph.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/commit-graph.c b/commit-graph.c index 2b52818731..2dd9bcc7ea 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -907,7 +907,7 @@ struct commit *lookup_commit_in_graph(struct repository *repo, const struct obje return NULL; if (!search_commit_pos_in_graph(id, repo->objects->commit_graph, &pos)) return NULL; - if (!repo_has_object_file(repo, id)) + if (!has_object(repo, id, 0)) return NULL; commit = lookup_commit(repo, id); |