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

Re: Finding a branch point in git

From
Jeff King <peff@peff.net>
Date
May 28, 2012, 19:06 UTC
Message-ID
<20120528190639.GA2478@sigill.intra.peff.net>
In-Reply-To
<CAMP44s04msWMOaaH8U30XXg5yXJnEd=bULJ7VPxWSD0Wfh2=EA@mail.gmail.com>
On Mon, May 28, 2012 at 02:36:04PM +0200, Felipe Contreras wrote:
Show 11 quoted lines
> > What about a history with multiple branches?
> >
> > --X--A--B--C--D----E  (master)
> >      \           /
> >       G--H--I---J   (branch X)
> >           \    /
> >            K--L    (branch Y)
> [...]
> 
> Yes, but then you would need to specify a second branch. I would avoid
> that if possible.

I agree that is less nice. But I don't think the operation is well-defined with a single branch. If you ask for "when did branch X split", then in the above graph it is unclear if you meant "split from master", or "split from Y".

Maybe you could assume "master", or assume "git symbolic-ref HEAD" as the second branch?

Show 8 quoted lines
> There's also another case that doesn't work:
> 
> -- X -- A -- B (master)
>          \
>           \
>            C (branch A)
> 
> Shouldn't be hard to add checks for those cases I think.

Actually, I think that one extends naturally. They are never merged, so your rev-list never finds a merge commit, and you can just take the merge base of the branch tips.

-Peff
Previous: Felipe ContrerasNext: Felipe Contreras
Message 4 of 13 in “Finding a branch point in git”
  1. Felipe ContrerasMay 27, 2012
  2. Jeff KingMay 28, 2012
  3. Felipe ContrerasMay 28, 2012
  4. Jeff KingMay 28, 2012
  5. Felipe ContrerasMay 30, 2012
  6. Jeff KingMay 30, 2012
  7. Felipe ContrerasMay 31, 2012
  8. Felipe ContrerasMay 31, 2012
  9. PJ WeisbergMay 31, 2012
  10. Felipe ContrerasJun 1, 2012
  11. Martin LanghoffMay 31, 2012
  12. Felipe ContrerasMay 30, 2012
  13. Jeff KingMay 30, 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.