git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Artur Skawina <art.08.09@gmail.com>
To: Seth Robertson <in-gitvger@baka.org>
Cc: git@vger.kernel.org
Subject: Re: Find out on which branch a commit was originally made
Date: Mon, 20 Sep 2010 03:31:41 +0200	[thread overview]
Message-ID: <4C96B97D.6030209@gmail.com> (raw)
In-Reply-To: <201009192354.o8JNsVLs018778@no.baka.org>

On 09/20/10 01:54, Seth Robertson wrote:
> In message <4C9698C5.70607@gmail.com>, Artur Skawina writes:
> 
> On 09/20/10 00:03, Seth Robertson wrote:
>>>>>>                A---B---C topic
>>>>>>               /         \
>>>>>>          D---E---F---G---H---I---J---K---L---M---N master
>>>>>>                                   \         /
>>>>>>                                    O---P---Q another-topic
>>>
>>>>> No, that's not what I need either.  After thinking about it more, I
>>>>> think what I want is "of all merges in the ancestry path from B to
>>>>> master, show only those whose first parent can't reach B."  The result
>>>>> is the list of all merges that were involved in bringing B to master.
>>>
>>>
>>>> This would work, and i don't see a way to optimize it in git-speak,
>>>> given that you don't want to see any extra trailing merges. [...]
>>>
>>> The provided command actually doesn't work for me for all cases.  It
>>> works for the simple case of "B", but does not work for "F", because F
>>> saw merge H & M.  I think we need --not --first-parent, except that
>>
>> Well, F was never on a separate branch, so the command returning ""
>> is arguably the right thing.
> 
> I'd like a command that would tell me the right branch something was
> on whether it was on master or topic or whatever.  If instead of
> "master" the branch was named "supertopic" and master commit AA had
> child D would that make a difference?

Like i said, "arguably". In theory, no, there is no difference. In
practice, some branches will be more long-lived than others -- and
certain conventions will apply. Hence, i think that answer /is/ the
right one, in context -- that script was specifically looking for
info on /another/ branch.

>>> doesn't actually work in this case either.  However, if we get the
>>> full --first-parent rev-list and look for our commit, that works.
>>> This is incredibly painful, though.
>>> ----------------------------------------------------------------------
>>> #!/bin/sh
>>> TARGET=`git rev-list -n 1 $1`
>>> git branch -a --contains $1 | sed 's/^\** *//' | grep -v ' -> ' |
>>> while read br; do
>>>  if git rev-list --first-parent $br | grep -q "$TARGET"; then
>>>   echo $br
>>>  fi
>>> done
>>> ----------------------------------------------------------------------
> 
>> And it does not work if you no longer have the branches around...
> 
> If something doesn't have a name I am not very interested in it (for
> my purposes, your milage may vary).  Presumably the other code could be
> combined with my inner loop.
> 
>> But even if you kept all the old refs, this would return
>> "another-topic"+"master", which is hardly the right answer.
> 
> I'm not sure how you can figure out when a branch was first created.
> We might "know" that master is older than the others, but if this
> commit was on another-topic and supertopic we cannot use that
> intuition..
> 
> Returning all possible branch names at least gives the user somewhere
> to start and does not give them ones which are obviously insane.

If you want to find out on which branch a change was committed and
"master" is right for 'F', then the "another-topic" part of that
answer is problematic -- every commit on that branch is a descendant
of 'F", and so is everything in between $common_base ('J') and master.
If you /don't/ treat master as special (ie don't treat the first
parent as special) what is then the difference vs a simple
"git branch -a --contains F"?
IOW, why would the right answer for 'F' be both 'master' and
'another-topic', but for 'B' - just 'topic'?

artur

  reply	other threads:[~2010-09-20  1:31 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-18  9:19 Find out on which branch a commit was originally made Stefan Haller
2010-09-18  9:58 ` Ævar Arnfjörð Bjarmason
2010-09-18 10:02   ` Ævar Arnfjörð Bjarmason
2010-09-18 11:28   ` Tor Arntsen
2010-09-18 15:26   ` Stefan Haller
2010-09-18 16:41     ` Artur Skawina
2010-09-19  9:45       ` Stefan Haller
2010-09-19 12:54         ` Clemens Buchacher
2010-09-19 14:03         ` Artur Skawina
2010-09-19 14:08         ` Stefan Haller
2010-09-19 16:38           ` Artur Skawina
2010-09-19 18:30     ` Robin Rosenberg
2010-09-19 22:03       ` Seth Robertson
2010-09-19 23:12         ` Artur Skawina
2010-09-19 23:54           ` Seth Robertson
2010-09-20  1:31             ` Artur Skawina [this message]
2010-09-20  5:47               ` Seth Robertson
2010-09-20  8:12                 ` Stefan Haller
2010-09-20 10:58                   ` Artur Skawina
2010-09-20 15:49                     ` Artur Skawina
2010-09-21  0:15                       ` Seth Robertson
2010-09-21  2:12                         ` Artur Skawina
2010-09-22 16:35                           ` ANNOUNCE git-what-branch (was Re: Find out on which branch a commit was originally made) Seth Robertson
2010-09-22 20:27                             ` Artur Skawina
2010-09-22 23:26                               ` Find out on which branch a commit was originally made) (was ANNOUNCE git-what-branch) Seth Robertson
2010-09-23 13:14                                 ` Stephen Bash
2010-09-23 13:26                                   ` Ævar Arnfjörð Bjarmason
2010-09-23 21:32                                     ` Artur Skawina
2010-09-24  1:33                                       ` Artur Skawina
2010-09-24 20:57                                       ` Seth Robertson
2010-09-23 14:27                                   ` Seth Robertson
2010-09-20 18:20                     ` Find out on which branch a commit was originally made Stefan Haller
2010-09-24 18:26 ` Bryan Drewery

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=4C96B97D.6030209@gmail.com \
    --to=art.08.09@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=in-gitvger@baka.org \
    /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).