]> git.ipfire.org Git - thirdparty/git.git/commit
commit-graph.c: no lazy fetch in lookup_commit_in_graph()
authorHan Xin <hanxin.hx@bytedance.com>
Fri, 1 Jul 2022 01:34:30 +0000 (09:34 +0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 1 Jul 2022 06:00:32 +0000 (23:00 -0700)
commit3a1ea94a491e3e0bcbc2d55b4cfb0b9eacace608
tree00b748d6bb087da26ebc381535f9ac87691d1bf4
parentdc8c8deaa6b5847733bd7df011a4c7b7d1a64e0a
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>
commit-graph.c
t/t5330-no-lazy-fetch-with-commit-graph.sh [new file with mode: 0755]