Re: Find out on which branch a commit was originally made

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Stefan Haller <lists@xxxxxxxxxxxxxxxx> wrote:

> Artur Skawina <art.08.09@xxxxxxxxx> wrote:
> 
> > On 09/18/10 17:26, Stefan Haller wrote:
> > > Ævar Arnfjör? Bjarmason <avarab@xxxxxxxxx> 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.)
> 
> 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
> context.  Ideally it should stop at the first command that's common to
> topic and master.

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.

Here's what I came up with:

#!/bin/sh

git rev-list --ancestry-path --merges --reverse "$1".."${2-master}" \
  | while read ref
do
  if [ -z "$(git rev-list --ancestry-path "$1".."$ref"^)" ]
  then
    git --no-pager log -1 --pretty=oneline "$ref"
  fi
done

It's pretty inefficient, but seems to get the job done. Is there a
smarter way to achieve the same?

-Stefan


-- 
Stefan Haller
Berlin, Germany
http://www.haller-berlin.de/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]