shared: let the repository's own commit-graph vouch for reachability

Answering whether a commit is reachable walks history from every
published reference, down to the commit's generation. On linux.git that
costs 0.1s for a recent commit and over 2s for an old one, on every
commit, diff and snapshot page -- and crawlers request old commits as
readily as new ones.

A commit-graph written with --reachable lists the commits the references
reached at the time, so accept a commit that graph lists without the
walk. That makes the graph part of the check's contract: a graph written
from packed objects would vouch for every packed commit, and a graph
loaded from an alternate describes the shared database rather than this
repository, so only a graph in the repository's own object directory
counts. Operators have to know both to keep the check meaningful.

Commits newer than the graph still take the walk, which is short for
them. A commit whose reference was deleted stays served until the graph
is next rewritten in full; a --split write keeps it, even when it
merges layers.

Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
3 files changed