git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Artur Skawina <art.08.09@gmail.com>
To: Stefan Haller <lists@haller-berlin.de>
Cc: "Ævar Arnfjör? Bjarmason" <avarab@gmail.com>, git@vger.kernel.org
Subject: Re: Find out on which branch a commit was originally made
Date: Sun, 19 Sep 2010 16:03:42 +0200	[thread overview]
Message-ID: <4C96183E.7020208@gmail.com> (raw)
In-Reply-To: <1jp2d5s.1q4xl2w1f5ufljM%lists@haller-berlin.de>

On 09/19/10 11:45, Stefan Haller wrote:
> Artur Skawina <art.08.09@gmail.com> wrote:
> 
>> On 09/18/10 17:26, Stefan Haller wrote:
>>> Ævar Arnfjör? Bjarmason <avarab@gmail.com> wrote:
>>>>                      A---B---C topic
>>>>                     /         \
>>>>                D---E---F---G---H master
>>
>>> The question is the same though: if I hit commit B while blaming, how do
>>> I know what topic it was a part of?  For that, I need to find commit H
>>> which will tell me, right?  How do I do that?
>>
>> git rev-list --ancestry-path --merges --reverse B..master --format=oneline
> 
> Thanks, this is helpful.  (However, my co-workers will probably laugh at
> me if I suggest they remember a command such as this for what they think
> should be a very simple operation.)

An alias such as "git show-merges-since B" might help.

> There's a problem though for commits that are far back in history:
> 
>                A---B---C topic
>               /         \
>          D---E---F---G---H---I---J---K---L---M---N master
>                                   \         /
>                                    O---P---Q another-topic
> 
> Your command also shows M, which is not interesting at all in this

But you're only interested in the name of the original topic branch,
right? Then the first merge will tell you that; I omitted "| head -1"
from the cmdline above, just in case the history isn't as simple as
in this graph.

> context.  Ideally it should stop at the first command that's common to
> topic and master.  Is there an easy way to achieve that?

Well, as you've explicitly deleted the 'topic' ref, how is git supposed
to find it?

The above "git rev-list" will give you either the merge w/ the info you
are looking for, or a list of merge commits that you'll have to filter
(grep etc) to find the first one containing the answer.

>> IOW if you know you could still need the old branch info, make an alias
>> that doesn't actually delete the branch after merging, but moves the ref
>> away, eg 'topic-name' -> "merged/topic-name" or just adds a
>> "merged/topic-name" tag. Then simply checking from which "merged/*"
>> branch/tag the offending commit is reachable would be enough.
> 
> Same problem here: this also shows all branches that were created and
> merged after the original topic was merged.  (In the example above, it
> will also list another-topic.)  This makes it pretty much impossible to

Yes. "git merge-base master another-topic" would return 'J' and if 'B'
is still reachable from 'J' then 'another-topic' isn't the answer and
you have to keep looking. So it's a bit more complicated.

artur

  parent reply	other threads:[~2010-09-19 14:04 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 [this message]
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
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=4C96183E.7020208@gmail.com \
    --to=art.08.09@gmail.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=lists@haller-berlin.de \
    /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).