{"thread":{"id":"43897","subject":"Most recent revision that contains a string","startedAt":"2016-08-20T21:41:47Z","lastAt":"2016-08-23T19:36:50Z","messageCount":7,"participants":["Nikolaus Rath","Josh Triplett","Eric Wong","Andreas Schwab","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"299802","messageId":"87d1l3ce40.fsf@thinkpad.rath.org","threadId":"43897","inReplyTo":null,"subject":"Most recent revision that contains a string","fromName":"Nikolaus Rath","fromEmail":"nikolaus@rath.org","sentAt":"2016-08-20T21:41:35Z","receivedAt":"2016-08-20T21:41:47Z","isPatch":false,"sender":{"key":"nikolaus@rath.org","avatar":"https://gravatar.com/avatar/d3b6cdc023a0665882d5aac373c0115bcb36f730c2e4a4051061fefbaf7dd041?d=mp&s=160"},"body":"Hello,\n\nWhat's the easiest way to find the most recent revision (of any file in\nthe repository, including those that have been deleted in the current\nHEAD) that contains a given string?\n\nI was hoping that \"git grep\" would do this (like in Mercurial), but as\nfar as I can tell it only greps through the working copy. Or is there a\ntrick that I'm missing?\n\nThanks,\n-Nikolaus\n\n-- \nGPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F\nFingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F\n\n             »Time flies like an arrow, fruit flies like a Banana.«\n"},{"id":"299806","messageId":"20160821013040.4sfmg2v7rcovxxmb@x","threadId":"43897","inReplyTo":"87d1l3ce40.fsf@thinkpad.rath.org","subject":"Re: Most recent revision that contains a string","fromName":"Josh Triplett","fromEmail":"josh@joshtriplett.org","sentAt":"2016-08-21T01:30:42Z","receivedAt":"2016-08-21T01:30:59Z","isPatch":false,"sender":{"key":"josh@joshtriplett.org","avatar":"https://avatars.githubusercontent.com/u/162737?v=4"},"body":"On Sat, Aug 20, 2016 at 02:41:35PM -0700, Nikolaus Rath wrote:\n> Hello,\n> \n> What's the easiest way to find the most recent revision (of any file in\n> the repository, including those that have been deleted in the current\n> HEAD) that contains a given string?\n> \n> I was hoping that \"git grep\" would do this (like in Mercurial), but as\n> far as I can tell it only greps through the working copy. Or is there a\n> trick that I'm missing?\n\ngit grep can search through any arbitrary blob, tree, commit, or tag.\nSo you can search through HEAD~10, or HEAD~10:path/to/directory, or\nHEAD~10:path/to/file.  (You can also search the index with --cached, and\nvarious other options exist as well.)\n\nIf you want to find a change that introduces or removes a particular\nstring, you could use \"git log -S\".  That doesn't allow regexes, but it\nmight do what you want.  \"git grep\" will find occurrences of the string\nin the current version, and if it has been removed, \"git log -S\" will\nfind the removal.\n\nI don't know of any way to do that in one file-oriented step, searching\nbackward through the first occurrence of every path, including deleted\npaths.\n"},{"id":"299808","messageId":"20160821024647.GA19536@starla","threadId":"43897","inReplyTo":"87d1l3ce40.fsf@thinkpad.rath.org","subject":"Re: Most recent revision that contains a string","fromName":"Eric Wong","fromEmail":"e@80x24.org","sentAt":"2016-08-21T02:46:47Z","receivedAt":"2016-08-21T02:46:52Z","isPatch":false,"sender":{"key":"e@80x24.org","avatar":null},"body":"Nikolaus Rath <Nikolaus@rath.org> wrote:\n> What's the easiest way to find the most recent revision (of any file in\n> the repository, including those that have been deleted in the current\n> HEAD) that contains a given string?\n\nI normally do something like:\n\n\tgit log -r --raw -p -SSTRING\n\tgit log -r --raw -p -GREGEXP\n\nYou can also add --diff-filter=D to filter only on deletes.\n\n\nBtw, please don't set these headers on kernel.org lists:\n\n\tMail-Copies-To: never\n\tMail-Followup-To: git@vger.kernel.org\n\nLike any mail server, vger fails from time-to-time and\nreply-to-all prevents it from being a single point of failure.\nThanks.\n"},{"id":"299810","messageId":"m2mvk6iloy.fsf@linux-m68k.org","threadId":"43897","inReplyTo":"20160821013040.4sfmg2v7rcovxxmb@x","subject":"Re: Most recent revision that contains a string","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2016-08-21T08:13:33Z","receivedAt":"2016-08-21T08:13:49Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"On Aug 20 2016, Josh Triplett <josh@joshtriplett.org> wrote:\n\n> If you want to find a change that introduces or removes a particular\n> string, you could use \"git log -S\".  That doesn't allow regexes,\n\nIt does, actually, see --pickaxe-regex.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"299811","messageId":"20160821084837.nyfnwefx5hteipcq@x","threadId":"43897","inReplyTo":"m2mvk6iloy.fsf@linux-m68k.org","subject":"Re: Most recent revision that contains a string","fromName":"Josh Triplett","fromEmail":"josh@joshtriplett.org","sentAt":"2016-08-21T08:48:37Z","receivedAt":"2016-08-21T08:48:47Z","isPatch":false,"sender":{"key":"josh@joshtriplett.org","avatar":"https://avatars.githubusercontent.com/u/162737?v=4"},"body":"On Sun, Aug 21, 2016 at 10:13:33AM +0200, Andreas Schwab wrote:\n> On Aug 20 2016, Josh Triplett <josh@joshtriplett.org> wrote:\n> > If you want to find a change that introduces or removes a particular\n> > string, you could use \"git log -S\".  That doesn't allow regexes,\n> \n> It does, actually, see --pickaxe-regex.\n\nThanks; I found that after looking up \"git log -G\", which Eric Wong\nmentioned in another reply.\n"},{"id":"299858","messageId":"871t1ghe5s.fsf@thinkpad.rath.org","threadId":"43897","inReplyTo":"20160821024647.GA19536@starla","subject":"Re: Most recent revision that contains a string","fromName":"Nikolaus Rath","fromEmail":"nikolaus@rath.org","sentAt":"2016-08-22T18:06:07Z","receivedAt":"2016-08-22T18:06:29Z","isPatch":false,"sender":{"key":"nikolaus@rath.org","avatar":"https://gravatar.com/avatar/d3b6cdc023a0665882d5aac373c0115bcb36f730c2e4a4051061fefbaf7dd041?d=mp&s=160"},"body":"On Aug 21 2016, Eric Wong <e@80x24.org> wrote:\n> Nikolaus Rath <Nikolaus@rath.org> wrote:\n>> What's the easiest way to find the most recent revision (of any file in\n>> the repository, including those that have been deleted in the current\n>> HEAD) that contains a given string?\n>\n> I normally do something like:\n>\n> \tgit log -r --raw -p -SSTRING\n> \tgit log -r --raw -p -GREGEXP\n>\n> You can also add --diff-filter=D to filter only on deletes.\n\nGreat, thanks!\n\n> Btw, please don't set these headers on kernel.org lists:\n>\n> \tMail-Copies-To: never\n> \tMail-Followup-To: git@vger.kernel.org\n>\n> Like any mail server, vger fails from time-to-time and\n> reply-to-all prevents it from being a single point of failure.\n\nHuh? If the list-server fails only I will receive the message so it's\nstill lost for everyone else. But I am more than happy to take this\nlittle risk if it saves me from the nuisance of getting duplicate\nresponses.\n\nBest,\n-Nikolaus\n\n-- \nGPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F\nFingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F\n\n             »Time flies like an arrow, fruit flies like a Banana.«\n"},{"id":"299982","messageId":"xmqqr39fuvjy.fsf@gitster.mtv.corp.google.com","threadId":"43897","inReplyTo":"871t1ghe5s.fsf@thinkpad.rath.org","subject":"Re: Most recent revision that contains a string","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-08-23T19:36:33Z","receivedAt":"2016-08-23T19:36:50Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nikolaus Rath <Nikolaus@rath.org> writes:\n\n>> Btw, please don't set these headers on kernel.org lists:\n>>\n>> \tMail-Copies-To: never\n>> \tMail-Followup-To: git@vger.kernel.org\n>>\n>> Like any mail server, vger fails from time-to-time and\n>> reply-to-all prevents it from being a single point of failure.\n>\n> Huh? If the list-server fails only I will receive the message so it's\n> still lost for everyone else. But I am more than happy to take this\n> little risk if it saves me from the nuisance of getting duplicate\n> responses.\n\nOn a mailing list, your readers' time is more valuable than yours,\nsimply because there are a lot more of them.\n\nI am typing this message ONLY because I want to talk to YOU, and I\nwant your address to be on its To: field, with Eric and the list on\nCc: field.  The recipients can prioritize their incoming messages by\nreading what's addressed directly to them first and when they have\nleftover time they can read ones that they are CC'ed, but because\nyou used Mail-Followup-To: I had to correct the headers manually,\nwhich means you stole time from me.  And if I didn't then your\nMail-Followup-to: would have stolen time from the other recipients.\n\nPlease don't use it on this list.\n\n"}]}