The connectivity check run by check_connected() calls rev-list with --alternate-refs so the walk stops at the refs of any alternate object store. Igor Wiedler reports that this only works because the option comes after --not. Since cf1e7c0770, deepening fetches drop "--not --all", so --alternate-refs becomes a positive revision and the check walks the alternate's entire history. With a 7M-object alternate, the check took 227 seconds after a fetch that received an empty pack.

The first version dropped --alternate-refs for deepening fetches. Junio C Hamano suggested negating it in both cases instead. The second version does that and moves --alternate-refs next to --all so the comment above --not covers all the boundary arguments. Junio also pointed Wiedler to the list's usual practice of discussing a patch before sending an updated series.

The second version adds a patch to odb_for_each_alternate_ref(). Its three callers (rev-list --alternate-refs, fetch-pack and receive-pack) treat alternate refs as commits whose history is present. Wiedler says that does not hold for a shallow or grafted alternate, because a borrowing repository does not see the alternate's shallow file. The patch makes the function ignore the refs of such alternates.

Justin Tobler summarized the reasoning and said he had first assumed the alternate refs should still be negated. Junio thanked Wiedler for spotting what he called an eight-year-old mistake. He then asked whether the same argument about trusting refs applies to a fully populated repository making a non-deepening fetch. The excerpt cuts off before the rest of his reasoning.

Patrick Steinhardt said he had reviewed the patch internally, so he had little to object to. He agreed that a test would be roundabout: one could corrupt history in the alternate and check that the walk hits it, but he questioned whether that is worth it. No test has been added in the excerpts.