Jeff King [off-list ref] writes:
Is it that cheap? A full reachability check for something that is not in
any ref would involve going to the roots, wouldn't it?
You only need to dig until you hit a merge base, no?
In this case, you would need to compute just one merge base, between the
commit you are about to leave, and the (imaginary) commit that is a merge
across all the tips of your refs. If the merge base is the commit you are
about to leave, you were sightseeing in the past without creating anything
new, otherwise you will lose commits between the computed base and the
commit you are about to leave.
And merge-base has an interface to compute exactly that, I think.