# git cherry to find equivalent commit IDs?

3 messages from 2009-08-13 to 2009-08-13. Participants: skillzero@gmail.com, Avery Pennarun.
Thread: https://gitlist.dev/t/20590

## skillzero@gmail.com, 2009-08-13 21:13

Subject: git cherry to find equivalent commit IDs?
Message-ID: <2729632a0908131413w1a2efca8t31ac8cc43e1d6888@mail.gmail.com>
URL: https://gitlist.dev/e/2729632a0908131413w1a2efca8t31ac8cc43e1d6888%40mail.gmail.com

```
Is there a way to get the commit ID of a patch that was cherry picked
(or via a manually applied patch)? I'm trying to get an equivalent to
git branch --contains, but instead of comparing the commit ID, it
compares patch IDs so it works for cherry picks and manual patches. It
seems like git cherry almost does what I want, but it only seems to
show the commit ID of the commit on the other branch rather than the
branch I specify to git cherry. I may just be using git cherry
incorrectly though.

For example, commit 3642151 on branch A was a cherry pick of a commit
460050c on master:

$ git branch -a --contains 3642151
  A

$ git branch -a --contains 460050c
* master

$ git cherry -v master 3642151
- 3642151435ce5737debc1213de46dd556475bfad1 fixed bug

I assume that means an equivalent change to 3642151 is already in
master (which it is, as commit 460050c). But I want to find out the
commit ID on master that's equivalent to 3642151 (i.e. something that
tells me it's 460050c).

I'm basically looking for something like git branch --contains, but
that searches by patch ID so it can find cherry picked or manually
applied patches:

$ git branch -a --contains-equivalent 3642151
* master (via commit 460050c)
  A (via commit 3642151)

Is there a way to do that?

```

## Avery Pennarun, 2009-08-13 21:37

Subject: Re: git cherry to find equivalent commit IDs?
Message-ID: <32541b130908131437g7cb14a1eh6cd2e31a57f105d5@mail.gmail.com>
URL: https://gitlist.dev/e/32541b130908131437g7cb14a1eh6cd2e31a57f105d5%40mail.gmail.com
In-Reply-To: <2729632a0908131413w1a2efca8t31ac8cc43e1d6888@mail.gmail.com>

```
On Thu, Aug 13, 2009 at 9:13 PM, <skillzero@gmail.com> wrote:
> For example, commit 3642151 on branch A was a cherry pick of a commit
> 460050c on master:
>
> $ git branch -a --contains 3642151
>  A
>
> $ git branch -a --contains 460050c
> * master
>
> $ git cherry -v master 3642151
> - 3642151435ce5737debc1213de46dd556475bfad1 fixed bug
>
> I assume that means an equivalent change to 3642151 is already in
> master (which it is, as commit 460050c). But I want to find out the
> commit ID on master that's equivalent to 3642151 (i.e. something that
> tells me it's 460050c).

git show 3642151 | git patch-id

You should get a line with two hashes; the first is the patchid (call
it PATCHID_FROM_ABOVE)

git log -p | git patch-id | grep PATCHID_FROM_ABOVE

This should give you a list of all commits that correspond to that patchid.

Note that if there were conflicts when applying the patch, the patchid
probably changed.

Have fun,

Avery

```

## skillzero@gmail.com, 2009-08-13 23:05

Subject: Re: git cherry to find equivalent commit IDs?
Message-ID: <2729632a0908131605p62b5e7ddjef9732baea0be84d@mail.gmail.com>
URL: https://gitlist.dev/e/2729632a0908131605p62b5e7ddjef9732baea0be84d%40mail.gmail.com
In-Reply-To: <32541b130908131437g7cb14a1eh6cd2e31a57f105d5@mail.gmail.com>

```
On Thu, Aug 13, 2009 at 2:37 PM, Avery Pennarun<apenwarr@gmail.com> wrote:
> On Thu, Aug 13, 2009 at 9:13 PM, <skillzero@gmail.com> wrote:
>> For example, commit 3642151 on branch A was a cherry pick of a commit
>> 460050c on master:
>>
>> $ git branch -a --contains 3642151
>>  A
>>
>> $ git branch -a --contains 460050c
>> * master
>>
>> $ git cherry -v master 3642151
>> - 3642151435ce5737debc1213de46dd556475bfad1 fixed bug
>>
>> I assume that means an equivalent change to 3642151 is already in
>> master (which it is, as commit 460050c). But I want to find out the
>> commit ID on master that's equivalent to 3642151 (i.e. something that
>> tells me it's 460050c).
>
> git show 3642151 | git patch-id
>
> You should get a line with two hashes; the first is the patchid (call
> it PATCHID_FROM_ABOVE)
>
> git log -p | git patch-id | grep PATCHID_FROM_ABOVE
>
> This should give you a list of all commits that correspond to that patchid.

That worked perfectly. Thanks.

```
