* Finding a commit
@ 2009-10-21 11:29 Soham Mehta
2009-10-21 12:30 ` Daniele Segato
2009-10-21 13:26 ` Douglas Campos
0 siblings, 2 replies; 6+ messages in thread
From: Soham Mehta @ 2009-10-21 11:29 UTC (permalink / raw)
To: git
Given a SHA1 of a commit from one repository (say x), wondering what is
a proper way to find out if that commit (change) also exists in a
different repository (say y).
Because SHA1 can change if a commit is cherry-picked around, I cannot
just grep for that SHA1 from git-rev-list or git-log on 'y'. I need a
way to know if a commit with identical changes (as in 'x') is also
present in 'y'.
I realize that Author and Timestamp do not change when the commit is
moved (fetched, pushed, pulled, rebased, cherry-picked etc). So my
current solution relies on grepping for the pair of Author-Timestamp
from git-log on 'y'.
Wondering if there is more appropriate way of doing this?
Thanks.
-Soham
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Finding a commit
2009-10-21 11:29 Soham Mehta
@ 2009-10-21 12:30 ` Daniele Segato
2009-10-21 12:37 ` Thomas Rast
2009-10-21 13:26 ` Douglas Campos
1 sibling, 1 reply; 6+ messages in thread
From: Daniele Segato @ 2009-10-21 12:30 UTC (permalink / raw)
To: Soham Mehta; +Cc: git
On Wed, Oct 21, 2009 at 1:29 PM, Soham Mehta <soham@box.net> wrote:
> Because SHA1 can change if a commit is cherry-picked around, I cannot just
> grep for that SHA1 from git-rev-list or git-log on 'y'. I need a way to know
> if a commit with identical changes (as in 'x') is also present in 'y'.
I'm really not an expert of git..
but A commit is something like:
Commit -> Tree ---> Blob1, Blob2, Blob3
Commit, Trees and Blobs are all identified by sha1
the commit should keep information on the author, the "parent"
commit(s) and so on..
the tree should just keep the "snapshot" of the data..
so I think that if you search for the SHA-1 of the tree you should be fine..
But I don't know how you can get the SHA-1 of the tree from a commit
(may be git cat-file <commit-sha> could help you)
and I don't know how to search for that tree around your index...
But I'm sure google (or whatever) has the answer to those questions,
regards,
Daniele
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Finding a commit
2009-10-21 12:30 ` Daniele Segato
@ 2009-10-21 12:37 ` Thomas Rast
2009-10-21 13:55 ` Daniele Segato
0 siblings, 1 reply; 6+ messages in thread
From: Thomas Rast @ 2009-10-21 12:37 UTC (permalink / raw)
To: Daniele Segato, Soham Mehta; +Cc: git
Daniele Segato wrote:
> On Wed, Oct 21, 2009 at 1:29 PM, Soham Mehta <soham@box.net> wrote:
> > Because SHA1 can change if a commit is cherry-picked around, I cannot just
> > grep for that SHA1 from git-rev-list or git-log on 'y'. I need a way to know
> > if a commit with identical changes (as in 'x') is also present in 'y'.
man git-patch-id (online at http://git.or.cz/man/git-patch-id).
Note that if the cherry-pick conflicted, you'll get a different
patch-id.
> I'm really not an expert of git..
>
> but A commit is something like:
>
> Commit -> Tree ---> Blob1, Blob2, Blob3
>
> Commit, Trees and Blobs are all identified by sha1
> the commit should keep information on the author, the "parent"
> commit(s) and so on..
> the tree should just keep the "snapshot" of the data..
>
> so I think that if you search for the SHA-1 of the tree you should be fine..
Not if you really want to find out if X was cherry-picked into this
repository, because the tree is the *final state* at that commit,
which of course includes all preceding changes.
So suppose you have two patches A.diff and B.diff introducing files of
the same name; then if you combine them into history as
A -- B
the tree state at B has both files, and hence is different from the
tree state of B' in
B' -- A'
because there it only has the file B.
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Finding a commit
2009-10-21 11:29 Soham Mehta
2009-10-21 12:30 ` Daniele Segato
@ 2009-10-21 13:26 ` Douglas Campos
1 sibling, 0 replies; 6+ messages in thread
From: Douglas Campos @ 2009-10-21 13:26 UTC (permalink / raw)
To: Soham Mehta; +Cc: git
On Wed, Oct 21, 2009 at 9:29 AM, Soham Mehta <soham@box.net> wrote:
> Given a SHA1 of a commit from one repository (say x), wondering what is a
> proper way to find out if that commit (change) also exists in a different
> repository (say y).
>
> Because SHA1 can change if a commit is cherry-picked around, I cannot just
> grep for that SHA1 from git-rev-list or git-log on 'y'. I need a way to know
> if a commit with identical changes (as in 'x') is also present in 'y'.
>
> I realize that Author and Timestamp do not change when the commit is moved
> (fetched, pushed, pulled, rebased, cherry-picked etc). So my current
> solution relies on grepping for the pair of Author-Timestamp from git-log on
> 'y'.
>
Have you tried git cherry?
--
Douglas Campos (qmx)
+55 11 7626 5959
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Finding a commit
2009-10-21 12:37 ` Thomas Rast
@ 2009-10-21 13:55 ` Daniele Segato
0 siblings, 0 replies; 6+ messages in thread
From: Daniele Segato @ 2009-10-21 13:55 UTC (permalink / raw)
To: Thomas Rast; +Cc: Soham Mehta, git
On Wed, Oct 21, 2009 at 2:37 PM, Thomas Rast <trast@student.ethz.ch> wrote:
>> Commit -> Tree ---> Blob1, Blob2, Blob3
>>
>> Commit, Trees and Blobs are all identified by sha1
>> the commit should keep information on the author, the "parent"
>> commit(s) and so on..
>> the tree should just keep the "snapshot" of the data..
>>
>> so I think that if you search for the SHA-1 of the tree you should be fine..
>
> Not if you really want to find out if X was cherry-picked into this
> repository, because the tree is the *final state* at that commit,
> which of course includes all preceding changes.
>
> So suppose you have two patches A.diff and B.diff introducing files of
> the same name; then if you combine them into history as
>
> A -- B
>
> the tree state at B has both files, and hence is different from the
> tree state of B' in
>
> B' -- A'
>
> because there it only has the file B.
Yes... obviously...
the tree is the snapshot of a complete data set: so if you apply the
same patch to different data set you get different trees...
thanks for pointing it out.. :)
Regards,
Daniele
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Finding a commit
@ 2009-10-22 8:32 Soham Mehta
0 siblings, 0 replies; 6+ messages in thread
From: Soham Mehta @ 2009-10-22 8:32 UTC (permalink / raw)
To: git
Thanks for all the answers! Sorry for the delayed reply.
Like Douglas Campos suggested, git-cherry (which uses git-patch-id like
Thomas Rast suggests) works for me. Here is what I tried:
from first repo$: git fetch second-repo
from first repo$: git cherry -v second-repo/branch-in-question sha1 sha1^
- sha1 <commit message>
Outputs the sha1 with a minus sign in front, which means the change is
already present in second-repo/branch-in-question, and is what I expect.
-Soham
thus spake Daniele Segato , On 10/21/2009 6:55 AM:
> On Wed, Oct 21, 2009 at 2:37 PM, Thomas Rast <trast@student.ethz.ch> wrote:
>
>>> Commit -> Tree ---> Blob1, Blob2, Blob3
>>>
>>> Commit, Trees and Blobs are all identified by sha1
>>> the commit should keep information on the author, the "parent"
>>> commit(s) and so on..
>>> the tree should just keep the "snapshot" of the data..
>>>
>>> so I think that if you search for the SHA-1 of the tree you should be fine..
>>>
>> Not if you really want to find out if X was cherry-picked into this
>> repository, because the tree is the *final state* at that commit,
>> which of course includes all preceding changes.
>>
>> So suppose you have two patches A.diff and B.diff introducing files of
>> the same name; then if you combine them into history as
>>
>> A -- B
>>
>> the tree state at B has both files, and hence is different from the
>> tree state of B' in
>>
>> B' -- A'
>>
>> because there it only has the file B.
>>
>
> Yes... obviously...
> the tree is the snapshot of a complete data set: so if you apply the
> same patch to different data set you get different trees...
> thanks for pointing it out.. :)
>
> Regards,
> Daniele
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-10-22 8:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-22 8:32 Finding a commit Soham Mehta
-- strict thread matches above, loose matches on Subject: below --
2009-10-21 11:29 Soham Mehta
2009-10-21 12:30 ` Daniele Segato
2009-10-21 12:37 ` Thomas Rast
2009-10-21 13:55 ` Daniele Segato
2009-10-21 13:26 ` Douglas Campos
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).