{"thread":{"id":"48923","subject":"Find commit that referenced a blob first","startedAt":"2018-07-19T21:02:53Z","lastAt":"2018-07-19T22:45:15Z","messageCount":6,"participants":["Lars Schneider","Stefan Beller","Jeff King","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"353079","messageId":"C00CED1F-D685-40E5-A5CC-4040BFD82886@gmail.com","threadId":"48923","inReplyTo":null,"subject":"Find commit that referenced a blob first","fromName":"Lars Schneider","fromEmail":"larsxschneider@gmail.com","sentAt":"2018-07-19T21:02:47Z","receivedAt":"2018-07-19T21:02:53Z","isPatch":false,"sender":{"key":"larsxschneider@gmail.com","avatar":"https://avatars.githubusercontent.com/u/477434?v=4"},"body":"Hi,\n\nI have a blob hash and I would like to know what commit referenced \nthis blob first in a given Git repo.\n\nI could iterate through all commits sorted by date (or generation \nnumber) and then recursively search in the referenced trees until \nI find my blob. I wonder, is this the most efficient way to solve \nmy problem? Is there some trick/existing Git command that would \nperform this search more efficiently for large repos?\n\nThank you,\nLars\n"},{"id":"353084","messageId":"CAGZ79kbJnyRbeH8yMa=QaqNofA_Ek_SwmH5qRaCaq4cyQ26Kqg@mail.gmail.com","threadId":"48923","inReplyTo":"C00CED1F-D685-40E5-A5CC-4040BFD82886@gmail.com","subject":"Re: Find commit that referenced a blob first","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-07-19T21:19:34Z","receivedAt":"2018-07-19T21:19:47Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, Jul 19, 2018 at 2:02 PM Lars Schneider <larsxschneider@gmail.com> wrote:\n>\n> Hi,\n>\n> I have a blob hash and I would like to know what commit referenced\n> this blob first in a given Git repo.\n\ngit describe <blob>\n\nIf the given object refers to a blob, it will be described as\n<commit-ish>:<path>,\nsuch that the blob can be found at <path> in the <commit-ish>, which itself\ndescribes the first commit in which this blob occurs in a reverse\nrevision walk from HEAD.\n\nSince\n644eb60bd01 (builtin/describe.c: describe a blob, 2017-11-15)\n(included first in 2.16.0\n\nYou're welcome,\nStefan\n"},{"id":"353088","messageId":"E632E745-03C6-4C7F-9B3F-CB46C0D7FCA7@gmail.com","threadId":"48923","inReplyTo":"CAGZ79kbJnyRbeH8yMa=QaqNofA_Ek_SwmH5qRaCaq4cyQ26Kqg@mail.gmail.com","subject":"Re: Find commit that referenced a blob first","fromName":"Lars Schneider","fromEmail":"larsxschneider@gmail.com","sentAt":"2018-07-19T21:45:23Z","receivedAt":"2018-07-19T21:45:28Z","isPatch":false,"sender":{"key":"larsxschneider@gmail.com","avatar":"https://avatars.githubusercontent.com/u/477434?v=4"},"body":"\n> On Jul 19, 2018, at 11:19 PM, Stefan Beller <sbeller@google.com> wrote:\n> \n> On Thu, Jul 19, 2018 at 2:02 PM Lars Schneider <larsxschneider@gmail.com> wrote:\n>> \n>> Hi,\n>> \n>> I have a blob hash and I would like to know what commit referenced\n>> this blob first in a given Git repo.\n> \n> git describe <blob>\n> \n> If the given object refers to a blob, it will be described as\n> <commit-ish>:<path>,\n> such that the blob can be found at <path> in the <commit-ish>, which itself\n> describes the first commit in which this blob occurs in a reverse\n> revision walk from HEAD.\n> \n> Since\n> 644eb60bd01 (builtin/describe.c: describe a blob, 2017-11-15)\n> (included first in 2.16.0\n> \n> You're welcome,\n> Stefan\n\nAwesome! Thank you very much :-)\n\n- Lars"},{"id":"353089","messageId":"20180719214729.GA14323@sigill.intra.peff.net","threadId":"48923","inReplyTo":"CAGZ79kbJnyRbeH8yMa=QaqNofA_Ek_SwmH5qRaCaq4cyQ26Kqg@mail.gmail.com","subject":"Re: Find commit that referenced a blob first","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2018-07-19T21:47:30Z","receivedAt":"2018-07-19T21:47:33Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Jul 19, 2018 at 02:19:34PM -0700, Stefan Beller wrote:\n\n> > I have a blob hash and I would like to know what commit referenced\n> > this blob first in a given Git repo.\n> \n> git describe <blob>\n> \n> If the given object refers to a blob, it will be described as\n> <commit-ish>:<path>,\n> such that the blob can be found at <path> in the <commit-ish>, which itself\n> describes the first commit in which this blob occurs in a reverse\n> revision walk from HEAD.\n> \n> Since\n> 644eb60bd01 (builtin/describe.c: describe a blob, 2017-11-15)\n> (included first in 2.16.0\n\nHmm.\n\n  $ git describe cfbc47ee2d\n  fatal: No tags can describe '83adac3c57ad8cd2c8d44b525414b949950e316d'.\n  Try --always, or create some tags.\n\n  $ git describe --always cfbc47ee2d\n  83adac3c57:checkout-cache.c\n\nThat first output confused me for a moment. We can't produce a nice\ndescriptive name for the commit in question, so we punt on the whole\nthing.\n\nAnyway. I have found your diff --find-object to be more useful in\npractice. I.e.:\n\n  git log --find-object=cfbc47ee2d\n\nbecause I usually care less about a succinct name, and more about\ndigging into the history (so adding \"-p\", etc).\n\n-Peff\n"},{"id":"353099","messageId":"xmqqr2jydf6c.fsf@gitster-ct.c.googlers.com","threadId":"48923","inReplyTo":"CAGZ79kbJnyRbeH8yMa=QaqNofA_Ek_SwmH5qRaCaq4cyQ26Kqg@mail.gmail.com","subject":"Re: Find commit that referenced a blob first","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-07-19T22:38:35Z","receivedAt":"2018-07-19T22:38:40Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> On Thu, Jul 19, 2018 at 2:02 PM Lars Schneider <larsxschneider@gmail.com> wrote:\n>>\n>> Hi,\n>>\n>> I have a blob hash and I would like to know what commit referenced\n>> this blob first in a given Git repo.\n>\n> git describe <blob>\n>\n> If the given object refers to a blob, it will be described as\n> <commit-ish>:<path>,\n> such that the blob can be found at <path> in the <commit-ish>, which itself\n> describes the first commit in which this blob occurs in a reverse\n> revision walk from HEAD.\n\nYou walk from the latest to earlier commit (because there by\ndefinition can be is no reverse pointer from older to newer commit),\nand see if it has the blob, and stop when you find one.  Wouldn't it\ngenerally find the most recent use, not the earliest use as Lars\nseems to want?\n\n>\n> Since\n> 644eb60bd01 (builtin/describe.c: describe a blob, 2017-11-15)\n> (included first in 2.16.0\n>\n> You're welcome,\n> Stefan\n"},{"id":"353100","messageId":"CAGZ79kYAQwfHZBSVG6ShVO6FCBKVu3CeKJ7ZLsRGVkfV73WmYA@mail.gmail.com","threadId":"48923","inReplyTo":"xmqqr2jydf6c.fsf@gitster-ct.c.googlers.com","subject":"Re: Find commit that referenced a blob first","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-07-19T22:45:02Z","receivedAt":"2018-07-19T22:45:15Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, Jul 19, 2018 at 3:38 PM Junio C Hamano <gitster@pobox.com> wrote:\n\n> > If the given object refers to a blob, it will be described as\n> > <commit-ish>:<path>,\n> > such that the blob can be found at <path> in the <commit-ish>, which itself\n> > describes the first commit in which this blob occurs in a reverse\n> > revision walk from HEAD.\n>\n> You walk from the latest to earlier commit (because there by\n> definition can be is no reverse pointer from older to newer commit),\n\nbut a \"reverse walk from HEAD\" produces the commits to us in an order\nas if we were walking from earlier to latest?\n"}]}