git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael J Gruber <git@drmicha.warpmail.net>
To: Pascal Obry <pascal@obry.net>
Cc: "Santi Béjar" <santi@agolina.net>,
	"Git Mailing List" <git@vger.kernel.org>
Subject: Re: Finding the name of the parent branch?
Date: Fri, 30 Jan 2009 14:35:57 +0100	[thread overview]
Message-ID: <4983023D.40907@drmicha.warpmail.net> (raw)
In-Reply-To: <a2633edd0901300456y48e8d78fn199675f2ae105c8@mail.gmail.com>

Pascal Obry venit, vidit, dixit 30.01.2009 13:56:
> 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...
> 
>> 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?

I think you still haven't *defined* what you mean by "parent branch".
Your example alone doesn't define it, and whenever you have merge
commits things are not clear:

     o---o---o---A
    /     \
---o       o---o---C
    \     /
     o---o---o---B

Now, which one is the "parent branch" of C? A+B? Similarly:

     o---A
    /
---o---C
    \
     o---B

Here it's clear which commit you want, but which branch does it belong
to? A or B?

I really think this is impossible to define unambiguously in git, due to
the nature of git branches, being movable tags, much different from say
hg's hardwired branches (embedded in the commit object).

What you see in gitk is which branch contains a certain commit ("git
branch --contains").

What you want may be the branch which differs from C by the least number
of commits.

Cheers,
Michael

  parent reply	other threads:[~2009-01-30 13:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-30 10:56 Finding the name of the parent branch? Pascal Obry
2009-01-30 11:18 ` Santi Béjar
2009-01-30 12:56   ` Pascal Obry
2009-01-30 13:16     ` Santi Béjar
2009-01-30 13:35       ` Pascal Obry
2009-01-30 13:57         ` Santi Béjar
2009-01-30 14:06           ` Pascal Obry
2009-01-30 14:46             ` Santi Béjar
2009-01-30 13:35     ` Michael J Gruber [this message]
2009-01-30 14:26 ` Thomas Koch
2009-01-30 15:58   ` Pascal Obry

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4983023D.40907@drmicha.warpmail.net \
    --to=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=pascal@obry.net \
    --cc=santi@agolina.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).