{"thread":{"id":"23608","subject":"\"git log -- SHA-1\" - how to get/simulate this functionality?","startedAt":"2010-04-26T17:54:25Z","lastAt":"2010-04-26T20:07:26Z","messageCount":7,"participants":["Eugene Sajine","Alex Riesen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"140432","messageId":"i2o76c5b8581004261054h591c266fre1a0dd87cd8511e1@mail.gmail.com","threadId":"23608","inReplyTo":null,"subject":"\"git log -- SHA-1\" - how to get/simulate this functionality?","fromName":"Eugene Sajine","fromEmail":"euguess@gmail.com","sentAt":"2010-04-26T17:54:25Z","receivedAt":"2010-04-26T17:54:25Z","isPatch":false,"sender":{"key":"euguess@gmail.com","avatar":null},"body":"Hi,\n\nI'm wondering if there is a way to get some repo information if the\nonly thing i know is SHA-1 (no full path to the file)\nThe current way seems to be a bit cumbersome\n\ngit log --no-abbrev --raw --all | grep SHA-1\n\nparse for path(s) and then git log -- path...\n\nI would want something like git log -- SHA-1\n\nAny ideas?\n\nThanks,\nEugene\n"},{"id":"140434","messageId":"x2z76c5b8581004261056lcdb153a5j825db166916069e9@mail.gmail.com","threadId":"23608","inReplyTo":"i2o76c5b8581004261054h591c266fre1a0dd87cd8511e1@mail.gmail.com","subject":"Re: \"git log -- SHA-1\" - how to get/simulate this functionality?","fromName":"Eugene Sajine","fromEmail":"euguess@gmail.com","sentAt":"2010-04-26T17:56:11Z","receivedAt":"2010-04-26T17:56:11Z","isPatch":false,"sender":{"key":"euguess@gmail.com","avatar":null},"body":"On Mon, Apr 26, 2010 at 1:54 PM, Eugene Sajine <euguess@gmail.com> wrote:\n> Hi,\n>\n> I'm wondering if there is a way to get some repo information if the\n> only thing i know is SHA-1 (no full path to the file)\n\nI mean of course the SHA-1 of the blob, i.e. the result of git\nhash-object some_file\n\n\nThanks,\nEugene\n"},{"id":"140437","messageId":"z2m81b0412b1004261108n5453b5d2h179a944fa8db9b49@mail.gmail.com","threadId":"23608","inReplyTo":"x2z76c5b8581004261056lcdb153a5j825db166916069e9@mail.gmail.com","subject":"Re: \"git log -- SHA-1\" - how to get/simulate this functionality?","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2010-04-26T18:08:09Z","receivedAt":"2010-04-26T18:08:09Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Mon, Apr 26, 2010 at 19:56, Eugene Sajine <euguess@gmail.com> wrote:\n> On Mon, Apr 26, 2010 at 1:54 PM, Eugene Sajine <euguess@gmail.com> wrote:\n>> Hi,\n>>\n>> I'm wondering if there is a way to get some repo information if the\n>> only thing i know is SHA-1 (no full path to the file)\n>\n> I mean of course the SHA-1 of the blob, i.e. the result of git\n> hash-object some_file\n\nTry 'git cat-file -t <sha>'. It prints what object type is under the hash.\nThan you can use either 'git cat-file <type> <sha>' (the most precise version,\nwhich shall fail if anything is wrong), 'git cat-file -p <sha>' or plain\n'git show <sha>' (which always works, unless repo's broken).\n"},{"id":"140440","messageId":"p2y76c5b8581004261122g8e2950fci507cc9090a865843@mail.gmail.com","threadId":"23608","inReplyTo":"z2m81b0412b1004261108n5453b5d2h179a944fa8db9b49@mail.gmail.com","subject":"Re: \"git log -- SHA-1\" - how to get/simulate this functionality?","fromName":"Eugene Sajine","fromEmail":"euguess@gmail.com","sentAt":"2010-04-26T18:22:45Z","receivedAt":"2010-04-26T18:22:45Z","isPatch":false,"sender":{"key":"euguess@gmail.com","avatar":null},"body":"On Mon, Apr 26, 2010 at 2:08 PM, Alex Riesen <raa.lkml@gmail.com> wrote:\n> On Mon, Apr 26, 2010 at 19:56, Eugene Sajine <euguess@gmail.com> wrote:\n>> On Mon, Apr 26, 2010 at 1:54 PM, Eugene Sajine <euguess@gmail.com> wrote:\n>>> Hi,\n>>>\n>>> I'm wondering if there is a way to get some repo information if the\n>>> only thing i know is SHA-1 (no full path to the file)\n>>\n>> I mean of course the SHA-1 of the blob, i.e. the result of git\n>> hash-object some_file\n>\n> Try 'git cat-file -t <sha>'. It prints what object type is under the hash.\n> Than you can use either 'git cat-file <type> <sha>' (the most precise version,\n> which shall fail if anything is wrong), 'git cat-file -p <sha>' or plain\n> 'git show <sha>' (which always works, unless repo's broken).\n>\n\nWell thank you for that, but that gives me what i already know - the content.\nI need to \"reverse engineer\" the history by having only the content\nand its SHA-1 in order to indentify the last commitID and get all\nrelevant info (author, date etc. )\n\nThis is all about avoiding using keyword expansion (thanks CVS for bad habbits)\n\nThanks,\nEugene\n"},{"id":"140443","messageId":"p2v81b0412b1004261157pf26db339t7d27b1b317a99b5e@mail.gmail.com","threadId":"23608","inReplyTo":"p2y76c5b8581004261122g8e2950fci507cc9090a865843@mail.gmail.com","subject":"Re: \"git log -- SHA-1\" - how to get/simulate this functionality?","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2010-04-26T18:57:38Z","receivedAt":"2010-04-26T18:57:38Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Mon, Apr 26, 2010 at 20:22, Eugene Sajine <euguess@gmail.com> wrote:\n> On Mon, Apr 26, 2010 at 2:08 PM, Alex Riesen <raa.lkml@gmail.com> wrote:\n>> On Mon, Apr 26, 2010 at 19:56, Eugene Sajine <euguess@gmail.com> wrote:\n>>> On Mon, Apr 26, 2010 at 1:54 PM, Eugene Sajine <euguess@gmail.com> wrote:\n>>>> Hi,\n>>>>\n>>>> I'm wondering if there is a way to get some repo information if the\n>>>> only thing i know is SHA-1 (no full path to the file)\n>>>\n>>> I mean of course the SHA-1 of the blob, i.e. the result of git\n>>> hash-object some_file\n>>\n>> Try 'git cat-file -t <sha>'. It prints what object type is under the hash.\n>> Than you can use either 'git cat-file <type> <sha>' (the most precise version,\n>> which shall fail if anything is wrong), 'git cat-file -p <sha>' or plain\n>> 'git show <sha>' (which always works, unless repo's broken).\n>>\n>\n> Well thank you for that, but that gives me what i already know - the content.\n> I need to \"reverse engineer\" the history by having only the content\n> and its SHA-1 in order to indentify the last commitID and get all\n> relevant info (author, date etc. )\n\nHmm. In that case, your using of git log look like a good way to get the\ninformation. If you wanted an output format which is better suited for\nautomated parsing, you can look at \"git rev-list --pretty=format:...\",\nlet it output only commit and tree hashes, and grep the output of\n\"git ls-tree\" for your hash...\n\n> This is all about avoiding using keyword expansion (thanks CVS for bad habbits)\n>\n> Thanks,\n> Eugene\n>\n"},{"id":"140450","messageId":"y2n81b0412b1004261237w1c9221dn1ac75a29f50cb74d@mail.gmail.com","threadId":"23608","inReplyTo":"p2v81b0412b1004261157pf26db339t7d27b1b317a99b5e@mail.gmail.com","subject":"Re: \"git log -- SHA-1\" - how to get/simulate this functionality?","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2010-04-26T19:37:41Z","receivedAt":"2010-04-26T19:37:41Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Mon, Apr 26, 2010 at 20:57, Alex Riesen <raa.lkml@gmail.com> wrote:\n> On Mon, Apr 26, 2010 at 20:22, Eugene Sajine <euguess@gmail.com> wrote:\n>> Well thank you for that, but that gives me what i already know - the content.\n>> I need to \"reverse engineer\" the history by having only the content\n>> and its SHA-1 in order to indentify the last commitID and get all\n>> relevant info (author, date etc. )\n>\n> Hmm. In that case, your using of git log look like a good way to get the\n> information. If you wanted an output format which is better suited for\n> automated parsing, you can look at \"git rev-list --pretty=format:...\",\n> let it output only commit and tree hashes, and grep the output of\n> \"git ls-tree\" for your hash...\n\nActually, \"git log --no-abbrev --raw --oneline\" looks very simple to parse.\nBy the way, you may get ambiguous results: any file any time could have\nhad the given hash. IOW, by looking at the whole history you may see different\nfiles having the same hash. It does mean the same content, so maybe its\nOK for your purposes.\n"},{"id":"140451","messageId":"g2l76c5b8581004261307g39f96c6en36588bfea6640ac5@mail.gmail.com","threadId":"23608","inReplyTo":"y2n81b0412b1004261237w1c9221dn1ac75a29f50cb74d@mail.gmail.com","subject":"Re: \"git log -- SHA-1\" - how to get/simulate this functionality?","fromName":"Eugene Sajine","fromEmail":"euguess@gmail.com","sentAt":"2010-04-26T20:07:26Z","receivedAt":"2010-04-26T20:07:26Z","isPatch":false,"sender":{"key":"euguess@gmail.com","avatar":null},"body":"On Mon, Apr 26, 2010 at 3:37 PM, Alex Riesen <raa.lkml@gmail.com> wrote:\n> On Mon, Apr 26, 2010 at 20:57, Alex Riesen <raa.lkml@gmail.com> wrote:\n>> On Mon, Apr 26, 2010 at 20:22, Eugene Sajine <euguess@gmail.com> wrote:\n>>> Well thank you for that, but that gives me what i already know - the content.\n>>> I need to \"reverse engineer\" the history by having only the content\n>>> and its SHA-1 in order to indentify the last commitID and get all\n>>> relevant info (author, date etc. )\n>>\n>> Hmm. In that case, your using of git log look like a good way to get the\n>> information. If you wanted an output format which is better suited for\n>> automated parsing, you can look at \"git rev-list --pretty=format:...\",\n>> let it output only commit and tree hashes, and grep the output of\n>> \"git ls-tree\" for your hash...\n>\n> Actually, \"git log --no-abbrev --raw --oneline\" looks very simple to parse.\n> By the way, you may get ambiguous results: any file any time could have\n> had the given hash. IOW, by looking at the whole history you may see different\n> files having the same hash. It does mean the same content, so maybe its\n> OK for your purposes.\n>\n\nYes this looks a bit better, but still not \"grep\"-able easily as grep\nSHA-1 cuts off the commit ID.\nI'm wondering why this \"simple\"  feature which actually solves\n(almost) the problem of \"keyword expansion\" substitution for git once\nand for all is not yet there...:(\n\nWhile i do realize that i might have ambiguous results and first of\nall because the same blob can exist in creation commits, modification\nand move, but mostly people are interested in the last commit of this\nparticular file/blob. So, i would say, it is very rare that at any\ngiven point of time there will be two objects with the same hash in\nrepo.\n\nIt is a feature request than:)\n\nPlease, somebody take a look at the possibility to develop a variant\nof \"git log\" or rev-list which would show the commits in which the\ngiven blob SHA-1 has participated.\n\nThanks,\nEugene\n"}]}