# Find a topic branch containing a commit

7 messages from 2016-07-27 to 2016-07-28. Participants: Duy Nguyen, Stefan Beller, Michael Haggerty, Junio C Hamano.
Thread: https://gitlist.dev/t/42941

## Duy Nguyen, 2016-07-27 17:42

Subject: Find a topic branch containing a commit
Message-ID: <CACsJy8CMnywB8AdmLxB8LnsznHrMTieoezhaQS=2r1pnM8ONZA@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8CMnywB8AdmLxB8LnsznHrMTieoezhaQS%3D2r1pnM8ONZA%40mail.gmail.com

```
Before I start doing anything silly because I don't know it can
already be done without waving my C wand like a mad man...

I often do this: find a commit of interest, the commit itself is not
enough so I need a full patch series to figure out what's going, so I
fire up "git log --graph --oneline" and manually search that commit
and trace back to the merge point, then I can "git log --patch". Is
there an automatic way to accomplish that? Something like "git branch
--contains" (or "git merge --contains")?

PS. Sometimes I wish we could optionally save cover letter in the
merge commit. Sometimes the "big plan" is hard to see by reading
individual commit messages.
-- 
Duy

```

## Stefan Beller, 2016-07-27 17:50

Subject: Re: Find a topic branch containing a commit
Message-ID: <CAGZ79kY5UrjSj8xbjB+MvTE2xUyt+te1RKN6Bf0WiEA23iZ7wg@mail.gmail.com>
URL: https://gitlist.dev/e/CAGZ79kY5UrjSj8xbjB%2BMvTE2xUyt%2Bte1RKN6Bf0WiEA23iZ7wg%40mail.gmail.com
In-Reply-To: <CACsJy8CMnywB8AdmLxB8LnsznHrMTieoezhaQS=2r1pnM8ONZA@mail.gmail.com>

```
On Wed, Jul 27, 2016 at 10:42 AM, Duy Nguyen <pclouds@gmail.com> wrote:
> Before I start doing anything silly because I don't know it can
> already be done without waving my C wand like a mad man...
>
> I often do this: find a commit of interest, the commit itself is not
> enough so I need a full patch series to figure out what's going, so I
> fire up "git log --graph --oneline" and manually search that commit
> and trace back to the merge point, then I can "git log --patch". Is
> there an automatic way to accomplish that? Something like "git branch
> --contains" (or "git merge --contains")?

https://github.com/mhagger/git-when-merged ?

>
> PS. Sometimes I wish we could optionally save cover letter in the
> merge commit. Sometimes the "big plan" is hard to see by reading
> individual commit messages.
> --
> Duy
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

```

## Stefan Beller, 2016-07-27 18:02

Subject: Re: Find a topic branch containing a commit
Message-ID: <CAGZ79kYNFoAUu+5Y0oh221UeyAB3zan_36RgrhZnSi19Oe2vcA@mail.gmail.com>
URL: https://gitlist.dev/e/CAGZ79kYNFoAUu%2B5Y0oh221UeyAB3zan_36RgrhZnSi19Oe2vcA%40mail.gmail.com
In-Reply-To: <CAGZ79kY5UrjSj8xbjB+MvTE2xUyt+te1RKN6Bf0WiEA23iZ7wg@mail.gmail.com>

```
On Wed, Jul 27, 2016 at 10:50 AM, Stefan Beller <sbeller@google.com> wrote:
>>
>> PS. Sometimes I wish we could optionally save cover letter in the
>> merge commit. Sometimes the "big plan" is hard to see by reading
>> individual commit messages.
>> --

I had this wish, too. That makes a lot of sense for merge commits,
although it doesn't work well with our current workflow I would presume,
because the merge commit happens at a different time than when Junio
picks up a patch series. And in the mean time, where would we
store the cover letter information to not get lost?

Note there are some external recordings instead of adding
it to the history itself, e.g. https://github.com/trast/git/tree/notes/gmane
annotated each commit with pointers to the mailing list archive.

```

## Duy Nguyen, 2016-07-27 18:03

Subject: Re: Find a topic branch containing a commit
Message-ID: <CACsJy8CKLmjW82TJHUoqrM1smmiP=dcDqvOpN_QDPePEy0ZuJw@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8CKLmjW82TJHUoqrM1smmiP%3DdcDqvOpN_QDPePEy0ZuJw%40mail.gmail.com
In-Reply-To: <CAGZ79kY5UrjSj8xbjB+MvTE2xUyt+te1RKN6Bf0WiEA23iZ7wg@mail.gmail.com>

```
On Wed, Jul 27, 2016 at 7:50 PM, Stefan Beller <sbeller@google.com> wrote:
> On Wed, Jul 27, 2016 at 10:42 AM, Duy Nguyen <pclouds@gmail.com> wrote:
>> Before I start doing anything silly because I don't know it can
>> already be done without waving my C wand like a mad man...
>>
>> I often do this: find a commit of interest, the commit itself is not
>> enough so I need a full patch series to figure out what's going, so I
>> fire up "git log --graph --oneline" and manually search that commit
>> and trace back to the merge point, then I can "git log --patch". Is
>> there an automatic way to accomplish that? Something like "git branch
>> --contains" (or "git merge --contains")?
>
> https://github.com/mhagger/git-when-merged ?

Beautiful. If it had an option to show a topic (i.e. git-log from
merge base to merge point) I would be ecstatic. Michael, any plans on
bringing this in C Git? For many topic-based projects this would be
very helpful addition, and I think it's not so hard to do it in C
either.
-- 
Duy

```

## Duy Nguyen, 2016-07-27 18:07

Subject: Re: Find a topic branch containing a commit
Message-ID: <CACsJy8AuP-E1qHM_sJ4ZPpZDSk3s1KkuQOLB9B38+OUkobO11g@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8AuP-E1qHM_sJ4ZPpZDSk3s1KkuQOLB9B38%2BOUkobO11g%40mail.gmail.com
In-Reply-To: <CAGZ79kYNFoAUu+5Y0oh221UeyAB3zan_36RgrhZnSi19Oe2vcA@mail.gmail.com>

```
On Wed, Jul 27, 2016 at 8:02 PM, Stefan Beller <sbeller@google.com> wrote:
> On Wed, Jul 27, 2016 at 10:50 AM, Stefan Beller <sbeller@google.com> wrote:
>>>
>>> PS. Sometimes I wish we could optionally save cover letter in the
>>> merge commit. Sometimes the "big plan" is hard to see by reading
>>> individual commit messages.
>>> --
>
> I had this wish, too. That makes a lot of sense for merge commits,
> although it doesn't work well with our current workflow I would presume,
> because the merge commit happens at a different time than when Junio
> picks up a patch series. And in the mean time, where would we
> store the cover letter information to not get lost?

We have config branch.xxx.description for that. If we teach git-am to
pick up (a selected portion of) the cover letter and save it in
branch.xxx.description (or even a new key like branch.xxx.mergeMsg)
then nothing is lost.
-- 
Duy

```

## Michael Haggerty, 2016-07-28 13:46

Subject: Re: Find a topic branch containing a commit
Message-ID: <a7cd0ee3-8281-b220-1acc-c9516325ecde@alum.mit.edu>
URL: https://gitlist.dev/e/a7cd0ee3-8281-b220-1acc-c9516325ecde%40alum.mit.edu
In-Reply-To: <CACsJy8CKLmjW82TJHUoqrM1smmiP=dcDqvOpN_QDPePEy0ZuJw@mail.gmail.com>

```
On 07/27/2016 08:03 PM, Duy Nguyen wrote:
> On Wed, Jul 27, 2016 at 7:50 PM, Stefan Beller <sbeller@google.com> wrote:
>> On Wed, Jul 27, 2016 at 10:42 AM, Duy Nguyen <pclouds@gmail.com> wrote:
>>> Before I start doing anything silly because I don't know it can
>>> already be done without waving my C wand like a mad man...
>>>
>>> I often do this: find a commit of interest, the commit itself is not
>>> enough so I need a full patch series to figure out what's going, so I
>>> fire up "git log --graph --oneline" and manually search that commit
>>> and trace back to the merge point, then I can "git log --patch". Is
>>> there an automatic way to accomplish that? Something like "git branch
>>> --contains" (or "git merge --contains")?
>>
>> https://github.com/mhagger/git-when-merged ?
> 
> Beautiful. If it had an option to show a topic (i.e. git-log from
> merge base to merge point) I would be ecstatic.

That's a good idea. I just created a pull request to add that feature:

    https://github.com/mhagger/git-when-merged/pull/13

Let me know what you think!

> Michael, any plans on
> bringing this in C Git? For many topic-based projects this would be
> very helpful addition, and I think it's not so hard to do it in C
> either.

I had no such plans, and I don't have time to work on that now. But I
certainly don't object if somebody else wants to work on it. It might
make a nice GSoC-sized project (though I'm not volunteering to be a
mentor at this time :-P ).

Michael


```

## Junio C Hamano, 2016-07-28 15:11

Subject: Re: Find a topic branch containing a commit
Message-ID: <xmqqa8h1u7a8.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqa8h1u7a8.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <a7cd0ee3-8281-b220-1acc-c9516325ecde@alum.mit.edu>

```
Michael Haggerty <mhagger@alum.mit.edu> writes:

> On 07/27/2016 08:03 PM, Duy Nguyen wrote:
>>>
>>> https://github.com/mhagger/git-when-merged ?
>> 
>> Beautiful. If it had an option to show a topic (i.e. git-log from
>> merge base to merge point) I would be ecstatic.
>
> That's a good idea. I just created a pull request to add that feature:
>
>     https://github.com/mhagger/git-when-merged/pull/13
>
> Let me know what you think!

It would be nice to have a mode to give the result in a more human
readable way.

I use when-merged to find where to queue a follow-on fix to a topic
that has already graduated to 'master'.  When the patch fixes an
earlier mistake of the commit X, "git when-merged X master" gives me
the merge's 40-hex object name, and the next step is almost always
to pass it to "git describe [--contains]".  This tells me down to
which maintenace track the fix can go.

Of course I can get that information by running a separate "git
describe [--contains] X", but when I'll be running "when-merged"
anyway, it is a wasted step.

Then "git show" of the found merge tells me where the tip of the
topic is and what the topic was called (older topic branches are
culled sometime after they are merged to 'master' and relevant
maintenance tracks), and allows me to queue the patch to the correct
place (after re-creating the topic if necessary).


    

```
