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

Re: Finding the name of the parent branch?

From
Pascal Obry <pascal@obry.net>
Date
Jan 30, 2009, 12:56 UTC
Message-ID
<a2633edd0901300456y48e8d78fn199675f2ae105c8@mail.gmail.com>
In-Reply-To
<adf1fd3d0901300318s5a0e4c94gab5f31342643ea52@mail.gmail.com>
Santi,
Thanks for you reply.
> I think your definition is not well defined. A, B and C are just
> branches of you project, technically they are equivalent. Maybe you
Right. Yet I want to know from which branch a branch as been started.
You need this to get the proper merge-base for example:
   $ git merge-base C A
      1
   $ git merge-base B C
      2
   $ git merge-base B A
      1

I always know on which topic branch I'm but, as shown above, depending on the parent branch passed to merge-base you do not get the same branch-point. This is fine.

So, when I'm in a topic branch I want to find the name of the parent branch. The one given when creating the branch:

   $ git branch B C

A "stupid" solution whould be to iterate over all branches. Looking for the merge-base and at the end output the branch having the youngest merge-base. I'm looking for something more efficient...

Show 14 quoted lines
> are thinking that the common commits of, say A and B, really belongs
> to A, but this is not the case they belong to both branches. In git a
> branch is really just a pointer to a commit and by extension the
> history, it is not a series of commits.
>
> Just a counterexample, just rearranging you graph:
>
>                        o---B
>                        /
>                   o---2---o---o---o---C
>                  /
>          ---o---1---o---o---o---A
>
> From you description: For B I would get C and for C I would get A.
Don't see this as a counter-example as it is exactly my example.
Did I missed something?
Pascal.
-- 
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
Previous: Santi BéjarNext: Santi Béjar
Message 3 of 11 in “Finding the name of the parent branch?”
  1. Pascal ObryJan 30, 2009
  2. Santi BéjarJan 30, 2009
  3. Pascal ObryJan 30, 2009
  4. Santi BéjarJan 30, 2009
  5. Pascal ObryJan 30, 2009
  6. Santi BéjarJan 30, 2009
  7. Pascal ObryJan 30, 2009
  8. Santi BéjarJan 30, 2009
  9. Michael J GruberJan 30, 2009
  10. Thomas KochJan 30, 2009
  11. Pascal ObryJan 30, 2009

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.