{"thread":{"id":"21302","subject":"Finding a commit","startedAt":"2009-10-21T11:29:25Z","lastAt":"2009-10-21T13:55:22Z","messageCount":5,"participants":["Soham Mehta","Daniele Segato","Thomas Rast","Douglas Campos"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"125585","messageId":"4ADEF095.3020406@box.net","threadId":"21302","inReplyTo":null,"subject":"Finding a commit","fromName":"Soham Mehta","fromEmail":"soham@box.net","sentAt":"2009-10-21T11:29:25Z","receivedAt":"2009-10-21T11:29:25Z","isPatch":false,"sender":{"key":"soham@box.net","avatar":null},"body":"Given a SHA1 of a commit from one repository (say x), wondering what is \na proper way to find out if that commit (change) also exists in a \ndifferent repository (say y).\n\nBecause SHA1 can change if a commit is cherry-picked around, I cannot \njust grep for that SHA1 from git-rev-list or git-log on 'y'. I need a \nway to know if a commit with identical changes (as in 'x') is also \npresent in 'y'.\n\nI realize that Author and Timestamp do not change when the commit is \nmoved (fetched, pushed, pulled, rebased, cherry-picked etc). So my \ncurrent solution relies on grepping for the pair of Author-Timestamp \nfrom git-log on 'y'.\n\nWondering if there is more appropriate way of doing this?\n\nThanks.\n-Soham\n"},{"id":"125590","messageId":"9accb4400910210530k75a763cbtbc9294d937de9242@mail.gmail.com","threadId":"21302","inReplyTo":"4ADEF095.3020406@box.net","subject":"Re: Finding a commit","fromName":"Daniele Segato","fromEmail":"daniele.bilug@gmail.com","sentAt":"2009-10-21T12:30:29Z","receivedAt":"2009-10-21T12:30:29Z","isPatch":false,"sender":{"key":"daniele.bilug@gmail.com","avatar":null},"body":"On Wed, Oct 21, 2009 at 1:29 PM, Soham Mehta <soham@box.net> wrote:\n> Because SHA1 can change if a commit is cherry-picked around, I cannot just\n> grep for that SHA1 from git-rev-list or git-log on 'y'. I need a way to know\n> if a commit with identical changes (as in 'x') is also present in 'y'.\n\nI'm really not an expert of git..\n\nbut A commit is something like:\n\nCommit -> Tree ---> Blob1, Blob2, Blob3\n\nCommit, Trees and Blobs are all identified by sha1\nthe commit should keep information on the author, the \"parent\"\ncommit(s) and so on..\nthe tree should just keep the \"snapshot\" of the data..\n\nso I think that if you search for the SHA-1 of the tree you should be fine..\n\nBut I don't know how you can get the SHA-1 of the tree from a commit\n(may be git cat-file <commit-sha> could help you)\nand I don't know how to search for that tree around your index...\n\nBut I'm sure google (or whatever) has the answer to those questions,\n\nregards,\nDaniele\n"},{"id":"125591","messageId":"200910211437.39166.trast@student.ethz.ch","threadId":"21302","inReplyTo":"9accb4400910210530k75a763cbtbc9294d937de9242@mail.gmail.com","subject":"Re: Finding a commit","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2009-10-21T12:37:37Z","receivedAt":"2009-10-21T12:37:37Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Daniele Segato wrote:\n> On Wed, Oct 21, 2009 at 1:29 PM, Soham Mehta <soham@box.net> wrote:\n> > Because SHA1 can change if a commit is cherry-picked around, I cannot just\n> > grep for that SHA1 from git-rev-list or git-log on 'y'. I need a way to know\n> > if a commit with identical changes (as in 'x') is also present in 'y'.\n\nman git-patch-id (online at http://git.or.cz/man/git-patch-id).\n\nNote that if the cherry-pick conflicted, you'll get a different\npatch-id.\n\n> I'm really not an expert of git..\n> \n> but A commit is something like:\n> \n> Commit -> Tree ---> Blob1, Blob2, Blob3\n> \n> Commit, Trees and Blobs are all identified by sha1\n> the commit should keep information on the author, the \"parent\"\n> commit(s) and so on..\n> the tree should just keep the \"snapshot\" of the data..\n> \n> so I think that if you search for the SHA-1 of the tree you should be fine..\n\nNot if you really want to find out if X was cherry-picked into this\nrepository, because the tree is the *final state* at that commit,\nwhich of course includes all preceding changes.\n\nSo suppose you have two patches A.diff and B.diff introducing files of\nthe same name; then if you combine them into history as\n\n  A -- B\n\nthe tree state at B has both files, and hence is different from the\ntree state of B' in\n\n  B' -- A'\n\nbecause there it only has the file B.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"125594","messageId":"ed88cb980910210626t750b4cc2r91d1dc22df14eb8b@mail.gmail.com","threadId":"21302","inReplyTo":"4ADEF095.3020406@box.net","subject":"Re: Finding a commit","fromName":"Douglas Campos","fromEmail":"douglas@theros.info","sentAt":"2009-10-21T13:26:36Z","receivedAt":"2009-10-21T13:26:36Z","isPatch":false,"sender":{"key":"douglas@theros.info","avatar":"https://gravatar.com/avatar/bca8e0e43e860dab00ec17dd3f1b60df6af911655fae70a0bbdeebeb889de421?d=mp&s=160"},"body":"On Wed, Oct 21, 2009 at 9:29 AM, Soham Mehta <soham@box.net> wrote:\n> Given a SHA1 of a commit from one repository (say x), wondering what is a\n> proper way to find out if that commit (change) also exists in a different\n> repository (say y).\n>\n> Because SHA1 can change if a commit is cherry-picked around, I cannot just\n> grep for that SHA1 from git-rev-list or git-log on 'y'. I need a way to know\n> if a commit with identical changes (as in 'x') is also present in 'y'.\n>\n> I realize that Author and Timestamp do not change when the commit is moved\n> (fetched, pushed, pulled, rebased, cherry-picked etc). So my current\n> solution relies on grepping for the pair of Author-Timestamp from git-log on\n> 'y'.\n>\n\nHave you tried git cherry?\n\n\n-- \nDouglas Campos (qmx)\n+55 11 7626 5959\n"},{"id":"125600","messageId":"9accb4400910210655i115686c5h2d38a885c1d56d2e@mail.gmail.com","threadId":"21302","inReplyTo":"200910211437.39166.trast@student.ethz.ch","subject":"Re: Finding a commit","fromName":"Daniele Segato","fromEmail":"daniele.bilug@gmail.com","sentAt":"2009-10-21T13:55:22Z","receivedAt":"2009-10-21T13:55:22Z","isPatch":false,"sender":{"key":"daniele.bilug@gmail.com","avatar":null},"body":"On Wed, Oct 21, 2009 at 2:37 PM, Thomas Rast <trast@student.ethz.ch> wrote:\n>> Commit -> Tree ---> Blob1, Blob2, Blob3\n>>\n>> Commit, Trees and Blobs are all identified by sha1\n>> the commit should keep information on the author, the \"parent\"\n>> commit(s) and so on..\n>> the tree should just keep the \"snapshot\" of the data..\n>>\n>> so I think that if you search for the SHA-1 of the tree you should be fine..\n>\n> Not if you really want to find out if X was cherry-picked into this\n> repository, because the tree is the *final state* at that commit,\n> which of course includes all preceding changes.\n>\n> So suppose you have two patches A.diff and B.diff introducing files of\n> the same name; then if you combine them into history as\n>\n>  A -- B\n>\n> the tree state at B has both files, and hence is different from the\n> tree state of B' in\n>\n>  B' -- A'\n>\n> because there it only has the file B.\n\nYes... obviously...\nthe tree is the snapshot of a complete data set: so if you apply the\nsame patch to different data set you get different trees...\nthanks for pointing it out.. :)\n\nRegards,\nDaniele\n"}]}