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>
This commit is contained in:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user