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

Re: [Q] Determing if a commit is reachable from the HEAD ?

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 20, 2012, 19:18 UTC
Message-ID
<7v7h0mfahx.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20120120180620.GA8504@codeaurora.org>
David Brown <davidb@codeaurora.org> writes:
Show 11 quoted lines
> On Fri, Jan 20, 2012 at 03:13:58PM +0100, Andreas Schwab wrote:
>> Brian Foster <brian.foster@maxim-ic.com> writes:
>> 
>> >  In a script, how can I determine commit Y is reachable
>> >  from the current HEAD ?
>> 
>> test $(git merge-base HEAD Y) = $(git rev-parse Y)
>
> Almost.  It works as long as there is only one merge base.  You really
> need to check if $(git rev-parse Y) is one of $(git merge-base --all
> HEAD Y)

Can you give us an example of a topology to which "merge-base --all HEAD Y" gives more than one output and Y is still reachable from HEAD?

It is my understanding that merge-base computation will give only Y and nothing else when Y is reachable from HEAD. I also think this assumption is used by some of the internal code in Git, and that is why I care.

Previous: David BrownNext: David Brown
Message 4 of 12 in “[Q] Determing if a commit is reachable from the HEAD ?”
  1. Brian FosterJan 20, 2012
  2. Andreas SchwabJan 20, 2012
  3. David BrownJan 20, 2012
  4. Junio C HamanoJan 20, 2012
  5. David BrownJan 20, 2012
  6. Junio C HamanoJan 21, 2012
  7. David BrownJan 21, 2012
  8. Sitaram ChamartyJan 20, 2012
  9. Brian FosterJan 23, 2012
  10. Junio C HamanoJan 23, 2012
  11. Brian FosterJan 24, 2012
  12. Brian FosterJan 24, 2012

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.