Subject: Re: Determining commit reachability

From: Artur Skawina <[email-masked]>
Date: Mon, 06 Sep 2010 07:04:33 +0200

On 09/06/10 05:17, Jeff King wrote:
> On Sun, Sep 05, 2010 at 10:34:11PM +0200, Artur Skawina wrote:
> 
>> Given commit C, refs (branches) R, S and T what would be the best way
>> to test whether 'C' is reachable from any of the heads?
>>
>> Checking if `git rev-list -n1 O ^R ^S ^T` produces any output is what
>> i came up with; is there a better (ie faster) solution?
> 
> I think that is about as fast as you will get. You could try something
> with git-merge-base, but it should be about the same speed.
> 
> Note that neither will tell you _which_ head the target was reachable
> from. For that, given the current interface you have to test each head

As i think i'll only need this to prevent leaking (private) commits that
wouldn't be reachable from the (public) heads, just  catching the
unreachable ones should be enough.

$ time git rev-list -n1 v2.6.12 ^v33 ^v35
0m2.333s user   0m0.040s system   0m2.379s elapsed   99.77% CPU
$ time git rev-list -n1 v2.6.36-rc2 ^v33 ^v35
76be97c1fc945db08aae1f1b746012662d643e97
0m0.500s user   0m0.010s system   0m0.514s elapsed   99.13% CPU

A bit expensive, but I guess should it become a problem I could cache
the result and/or blacklist the client.

Thanks,

artur