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

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

 



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.
The example I gave
(B->[merge of subtopic]->[merged to supertopic]->[merged to master])
was the case where "--not-first-parent" wouldn't help, even if such
an option would exist.

> 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...

But even if you kept all the old refs, this would return
"another-topic"+"master", which is hardly the right answer.

artur
--
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]