{"thread":{"id":"28830","subject":"How to find a commit that introduces (not removes) a string?","startedAt":"2011-11-03T09:50:18Z","lastAt":"2011-11-04T10:59:20Z","messageCount":4,"participants":["Sebastian Schuberth","Neal Kreitzinger","Vijay Lakshminarayanan"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"178762","messageId":"j8to8h$vqd$1@dough.gmane.org","threadId":"28830","inReplyTo":null,"subject":"How to find a commit that introduces (not removes) a string?","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2011-11-03T09:50:18Z","receivedAt":"2011-11-03T09:50:18Z","isPatch":false,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"Hi all,\n\nI know about git log's -S / -G, but I'm unable to make these search through *introduced* strings only. Is there a way to do so?\n\nThanks!\n\nPS: I also read [1], but although the author claims to be interested in introduced strings only, he seems to be satisfied with -G, which slightly puzzles me.\n\n[1] http://stackoverflow.com/questions/5816134/git-finding-a-commit-that-introduced-a-string\n\n-- \nSebastian Schuberth\n"},{"id":"178776","messageId":"4EB2B9A7.5090909@gmail.com","threadId":"28830","inReplyTo":"j8to8h$vqd$1@dough.gmane.org","subject":"Re: How to find a commit that introduces (not removes) a string?","fromName":"Neal Kreitzinger","fromEmail":"nkreitzinger@gmail.com","sentAt":"2011-11-03T15:56:23Z","receivedAt":"2011-11-03T15:56:23Z","isPatch":false,"sender":{"key":"nkreitzinger@gmail.com","avatar":null},"body":"On 11/3/2011 4:50 AM, Sebastian Schuberth wrote:\n> Hi all,\n>\n> I know about git log's -S / -G, but I'm unable to make these search through *introduced* strings only. Is there a way to do so?\n>\n> Thanks!\n>\n> PS: I also read [1], but although the author claims to be interested in introduced strings only, he seems to be satisfied with -G, which slightly puzzles me.\n>\n> [1] http://stackoverflow.com/questions/5816134/git-finding-a-commit-that-introduced-a-string\n>\nIf you are using linux, here is git diff command I use to find leftover \ndebug statements.  I imagine the -S option will work the same in git \nlog.  I pipe the results into grep to filter the results to show only \nthe additions. (I'm using git 1.7.1)\n\n$ git diff --unified=0 -S\"DEBUG\" <commit> <commit> -- <path> | grep -e \n\"diff --\" -e \"+\" | grep -v -e \"@@\" -e \"+++\"\n\nmaybe you will find this helpful.\n\nv/r,\nneal\n"},{"id":"178779","messageId":"87zkgdgp5q.fsf@gmail.com","threadId":"28830","inReplyTo":"j8to8h$vqd$1@dough.gmane.org","subject":"Re: How to find a commit that introduces (not removes) a string?","fromName":"Vijay Lakshminarayanan","fromEmail":"laksvij@gmail.com","sentAt":"2011-11-03T16:13:21Z","receivedAt":"2011-11-03T16:13:21Z","isPatch":false,"sender":{"key":"laksvij@gmail.com","avatar":null},"body":"Sebastian Schuberth <sschuberth@gmail.com> writes:\n\n> Hi all,\n>\n> I know about git log's -S / -G, but I'm unable to make these search through *introduced* strings only. Is there a way to do so?\n\nThis appears to work:\n\n$ for ref in `git log -SWORD --pretty=format:\"%h\"` ; do \n    git log -1 -p $ref | grep WORD | grep -E '^[+]' > /dev/null ; \n    if [ $? -eq 0 ]; then \n        echo $ref; \n    fi ;\n  done\n\nsubstitute WORD for what you're looking for.  Note that it is repeated\ntwice.\n\n> Thanks!\n>\n> PS: I also read [1], but although the author claims to be interested in introduced strings only, he seems to be satisfied with -G, which slightly puzzles me.\n>\n> [1] http://stackoverflow.com/questions/5816134/git-finding-a-commit-that-introduced-a-string\n\n-- \nCheers\n~vijay\n"},{"id":"178819","messageId":"4EB3C588.501@gmail.com","threadId":"28830","inReplyTo":"j8to8h$vqd$1@dough.gmane.org","subject":"Re: How to find a commit that introduces (not removes) a string?","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2011-11-04T10:59:20Z","receivedAt":"2011-11-04T10:59:20Z","isPatch":false,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"On 03.11.2011 10:50, Sebastian Schuberth wrote:\n\n> I know about git log's -S / -G, but I'm unable to make these search through *introduced* strings only. Is there a way to do so?\n\nThanks for your suggestions. However, I ended up simply doing\n\n$ git diff --no-color FROM..TO | grep ^+[^+] | grep WORD\n\nwhich works well for my case.\n\n-- \nSebastian Schuberth\n"}]}