git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Determining commit reachability

From
ASArtur Skawina <art.08.09@gmail.com>
Date
Sep 6, 2010, 05:04 UTC
Message-ID
<4C847661.3020800@gmail.com>
In-Reply-To
<20100906031700.GA25012@sigill.intra.peff.net>
On 09/06/10 05:17, Jeff King wrote:
Show 13 quoted lines
> 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
Previous: Jeff KingNext: Junio C Hamano
Message 3 of 13 in “Determining commit reachability”
  1. Artur SkawinaSep 5, 2010
  2. Jeff KingSep 6, 2010
  3. Artur SkawinaSep 6, 2010
  4. Junio C HamanoSep 6, 2010
  5. Sverre RabbelierSep 6, 2010
  6. Ævar Arnfjörð BjarmasonSep 6, 2010
  7. Sverre RabbelierSep 6, 2010
  8. Junio C HamanoSep 6, 2010
  9. Documentation: explain "git branch --with"Jonathan Nieder, Sep 7, 2010
  10. Ævar Arnfjörð BjarmasonSep 7, 2010
  11. Junio C HamanoSep 9, 2010
  12. Nguyen Thai Ngoc DuySep 7, 2010
  13. Nguyen Thai Ngoc DuySep 7, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.