Junio C Hamano <gitster@xxxxxxxxx> writes: > You only need to dig until you hit a merge base, no? > ... > And merge-base has an interface to compute exactly that, I think. Ah, forget "merge-base". In the kernel repository, the very old "v2.6.12" will participate in the (imaginary) merge across all the refs, and computing merge-base means we need to traverse down to it. We only need to prime a "struct revisions" with the detached HEAD as the sole positive, and the refs as negatives (i.e. UNINTERESTING), and walk the history the usual way, until we either (1) see HEAD painted uninteresting; or (2) the queue becomes all uninteresting. As soon as (1) happens, we know the HEAD is reachable from some ref, and we can immediately stop. When (2) happens, we inspect the HEAD again and if it is painted uninteresting then we know HEAD is reachable from some ref. Otherwise HEAD will become dangling when you leave it. That way, the traversal will terminate much sooner than computing the true merge base. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html