{"thread":{"id":"21155","subject":"git log -S not finding all commits?","startedAt":"2009-10-08T08:21:09Z","lastAt":"2009-10-09T14:33:42Z","messageCount":15,"participants":["Daniel","Andreas Ericsson","Matthieu Moy","Nanako Shiraishi","Randal L. Schwartz","Scott Wiersdorf"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"124370","messageId":"7ae12651.522df17b.4acda0f5.21a31@o2.pl","threadId":"21155","inReplyTo":null,"subject":"git log -S not finding all commits?","fromName":"Daniel","fromEmail":"mjucde@o2.pl","sentAt":"2009-10-08T08:21:09Z","receivedAt":"2009-10-08T08:21:09Z","isPatch":false,"sender":{"key":"mjucde@o2.pl","avatar":null},"body":"Hi,\n\nI did:\n\n$ git version\ngit version 1.6.4.4\n$ mkdir a && cd a && git init\n$ echo \"Free data\" > a\n$ git add a\n$ git commit -m1\n$ echo \"Free data allocated by other function\" > a\n$ git commit -a -m2\n$ PAGER=cat git log -S'Free' --oneline\n2f34241 1\n\nI would expect \"git log\" to show both 1 and 2 commit, but it prints only 1.\n\nIs it the correct behavior?\n\n-- \nDaniel\n"},{"id":"124372","messageId":"4ACDACE6.9060509@op5.se","threadId":"21155","inReplyTo":"7ae12651.522df17b.4acda0f5.21a31@o2.pl","subject":"Re: git log -S not finding all commits?","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2009-10-08T09:12:06Z","receivedAt":"2009-10-08T09:12:06Z","isPatch":false,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"On 10/08/2009 10:21 AM, Daniel wrote:\n> Hi,\n>\n> I did:\n>\n> $ git version\n> git version 1.6.4.4\n> $ mkdir a&&  cd a&&  git init\n> $ echo \"Free data\">  a\n> $ git add a\n> $ git commit -m1\n> $ echo \"Free data allocated by other function\">  a\n> $ git commit -a -m2\n> $ PAGER=cat git log -S'Free' --oneline\n> 2f34241 1\n>\n> I would expect \"git log\" to show both 1 and 2 commit, but it prints only 1.\n>\n> Is it the correct behavior?\n>\n\nYes, it's the correct behaviour. -S finds only lines where what you search\nfor was added or deleted. It counts the number of occurrences of what you\nspecify in each resulting tree and only shows the commits where that number\nchanged. In your case, searching for \"Free data \" would have printed both\ncommits, since you first introduce that entire string and then remove it.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n\nConsidering the successes of the wars on alcohol, poverty, drugs and\nterror, I think we should give some serious thought to declaring war\non peace.\n"},{"id":"124373","messageId":"362436ca.6b5d0fc3.4acdc7e1.41b23@o2.pl","threadId":"21155","inReplyTo":"4ACDACE6.9060509@op5.se","subject":"Re: git log -S not finding all commits?","fromName":"Daniel","fromEmail":"mjucde@o2.pl","sentAt":"2009-10-08T11:07:13Z","receivedAt":"2009-10-08T11:07:13Z","isPatch":false,"sender":{"key":"mjucde@o2.pl","avatar":null},"body":"Andreas Ericsson <ae@op5.se> wrote:\n\n> Yes, it's the correct behaviour. -S finds only lines where what you search\n> for was added or deleted. It counts the number of occurrences of what you\n> specify in each resulting tree and only shows the commits where that number\n> changed. In your case, searching for \"Free data \" would have printed both\n> commits, since you first introduce that entire string and then remove it.\n\nThanks. However, your suggestion doesn't work. It prints only commit 2. Maybe\nyou meant:\n\n$ PAGER=cat git log --pickaxe-regex -S'Free data$' --oneline\n\nbut that doesn't solve my problem. I want to find all commits which changed\nlines containing \"Free data\" (the example I posted is simplified).\n\nSeems I have to use \"git log -p\" and search its output using pager...\n\n-- \nDaniel\n"},{"id":"124374","messageId":"vpqbpkixgea.fsf@bauges.imag.fr","threadId":"21155","inReplyTo":"362436ca.6b5d0fc3.4acdc7e1.41b23@o2.pl","subject":"Re: git log -S not finding all commits?","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2009-10-08T11:40:45Z","receivedAt":"2009-10-08T11:40:45Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Daniel <mjucde@o2.pl> writes:\n\n> Andreas Ericsson <ae@op5.se> wrote:\n>\n>> Yes, it's the correct behaviour. -S finds only lines where what you search\n>> for was added or deleted. It counts the number of occurrences of what you\n>> specify in each resulting tree and only shows the commits where that number\n>> changed. In your case, searching for \"Free data \" would have printed both\n>> commits, since you first introduce that entire string and then remove it.\n>\n> Thanks. However, your suggestion doesn't work. It prints only commit 2. Maybe\n> you meant:\n>\n> $ PAGER=cat git log --pickaxe-regex -S'Free data$' --oneline\n>\n> but that doesn't solve my problem. I want to find all commits which changed\n> lines containing \"Free data\" (the example I posted is simplified).\n>\n> Seems I have to use \"git log -p\" and search its output using pager...\n\nSearch the ML's archives, this is a FAQ. People have proposed an\noption to allow log -S to actually search the diff (much slower, but\nsometimes what you really want), but AFAIK, no one wrote the code. But\nI think someone posted a small perl script along the lines of\n\ngit log -p --format=\"%s\\n%x00\"  | perl -0 -ne 'print if(/whatever-you-search/);'\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"124375","messageId":"vpq63aqxflu.fsf@bauges.imag.fr","threadId":"21155","inReplyTo":"vpqbpkixgea.fsf@bauges.imag.fr","subject":"Re: git log -S not finding all commits?","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2009-10-08T11:57:49Z","receivedAt":"2009-10-08T11:57:49Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> git log -p --format=\"%s\\n%x00\"  | perl -0 -ne 'print if(/whatever-you-search/);'\n\ngit log -p -z is better than my --format= indeed.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"124376","messageId":"49efcded.58cfa30b.4acddff5.4d773@o2.pl","threadId":"21155","inReplyTo":"vpq63aqxflu.fsf@bauges.imag.fr","subject":"Re: git log -S not finding all commits?","fromName":"Daniel","fromEmail":"mjucde@o2.pl","sentAt":"2009-10-08T12:49:57Z","receivedAt":"2009-10-08T12:49:57Z","isPatch":false,"sender":{"key":"mjucde@o2.pl","avatar":null},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:\n\n> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n> \n> > git log -p --format=\"%s\\n%x00\"  | perl -0 -ne 'print if(/whatever-you-search/);'\n> \n> git log -p -z is better than my --format= indeed.\n> \n> -- \n> Matthieu Moy\n> http://www-verimag.imag.fr/~moy/\n> \n\nThanks, it's practically what I was looking for.\n\n-- \nDaniel\n"},{"id":"124398","messageId":"vpqiqepeocu.fsf@bauges.imag.fr","threadId":"21155","inReplyTo":"49efcded.58cfa30b.4acddff5.4d773@o2.pl","subject":"Re: git log -S not finding all commits?","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2009-10-08T18:23:45Z","receivedAt":"2009-10-08T18:23:45Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Daniel <mjucde@o2.pl> writes:\n\n> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:\n>\n> > git log -p -z  | perl -0 -ne 'print if(/whatever-you-search/);'\n>\n> Thanks, it's practically what I was looking for.\n\nhttp://git.or.cz/gitwiki/GitFaq#A.22gitlog-S.22doesnotshowallcommits\n\nFeel free to improve.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"124404","messageId":"20091009070213.6117@nanako3.lavabit.com","threadId":"21155","inReplyTo":"7ae12651.522df17b.4acda0f5.21a31@o2.pl","subject":"Re: git log -S not finding all commits?","fromName":"Nanako Shiraishi","fromEmail":"nanako3@lavabit.com","sentAt":"2009-10-08T22:02:13Z","receivedAt":"2009-10-08T22:02:13Z","isPatch":false,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"Quoting Daniel <mjucde@o2.pl>\n\n> $ git version\n> git version 1.6.4.4\n> $ mkdir a && cd a && git init\n> $ echo \"Free data\" > a\n> $ git add a\n> $ git commit -m1\n> $ echo \"Free data allocated by other function\" > a\n> $ git commit -a -m2\n> $ PAGER=cat git log -S'Free' --oneline\n> 2f34241 1\n>\n> I would expect \"git log\" to show both 1 and 2 commit, but it prints only 1.\n>\n> Is it the correct behavior?\n\nJunio described how various features in git were invented to realize the goal of \"Linus's ultimate content tracking\" in his blog http://gitster.livejournal.com/35628.html (and he extended on the article in a chapter in his book that was published in Japan last month).\n\nThe \"pickaxe\" search is one of such components. It is meant to be given the block of lines you are interested in the newer version and used to find the commit that changes anything in the given block of lines. For details, see his blog article (item no. 3) at the above URL (and other items as well, if you are interested in learning the history of other notable features).\n\n-- \nNanako Shiraishi\nhttp://ivory.ap.teacup.com/nanako3/\n"},{"id":"124407","messageId":"86tyy9qz08.fsf@blue.stonehenge.com","threadId":"21155","inReplyTo":"vpq63aqxflu.fsf@bauges.imag.fr","subject":"Re: git log -S not finding all commits?","fromName":"Randal L. Schwartz","fromEmail":"merlyn@stonehenge.com","sentAt":"2009-10-08T22:52:55Z","receivedAt":"2009-10-08T22:52:55Z","isPatch":false,"sender":{"key":"merlyn@stonehenge.com","avatar":"https://gravatar.com/avatar/dc528d210743ff0333e6213f9ee7b33b23f1b7bc1f3c5a8c2d819074ecd7ab19?d=mp&s=160"},"body":">>>>> \"Matthieu\" == Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\nMatthieu> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n>> git log -p --format=\"%s\\n%x00\"  | perl -0 -ne 'print if(/whatever-you-search/);'\n\nThat \"if\" is noisier than it needs to be:\n\n  perl -0 -ne 'print if /this/'\n\nsuffices.\n\n-- \nRandal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095\n<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>\nSmalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.\nSee http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion\n"},{"id":"124442","messageId":"vpq1vldx7xx.fsf@bauges.imag.fr","threadId":"21155","inReplyTo":"86tyy9qz08.fsf@blue.stonehenge.com","subject":"Re: git log -S not finding all commits?","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2009-10-09T08:55:38Z","receivedAt":"2009-10-09T08:55:38Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"merlyn@stonehenge.com (Randal L. Schwartz) writes:\n\n>>>>>> \"Matthieu\" == Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n>\n> Matthieu> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n>>> git log -p --format=\"%s\\n%x00\"  | perl -0 -ne 'print if(/whatever-you-search/);'\n>\n> That \"if\" is noisier than it needs to be:\n>\n>   perl -0 -ne 'print if /this/'\n\nThanks,\n\nAlso, this seems to actually print the \\0 character. Perhaps a perl\nguru can give a simple solution to replace the \\0 by a \\n?\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"124484","messageId":"20091009124149.GA50560@perlcode.org","threadId":"21155","inReplyTo":"vpq1vldx7xx.fsf@bauges.imag.fr","subject":"Re: git log -S not finding all commits?","fromName":"Scott Wiersdorf","fromEmail":"scott@perlcode.org","sentAt":"2009-10-09T12:41:50Z","receivedAt":"2009-10-09T12:41:50Z","isPatch":false,"sender":{"key":"scott@perlcode.org","avatar":null},"body":"On Fri, Oct 09, 2009 at 10:55:38AM +0200, Matthieu Moy wrote:\n> >\n> >   perl -0 -ne 'print if /this/'\n> \n> Also, this seems to actually print the \\0 character. Perhaps a perl\n> guru can give a simple solution to replace the \\0 by a \\n?\n\nIf you want some indication that there is a null character:\n\n  perl -0 -ne '/this/ or next; s/\\0/{NULL}/g; print'\n\notherwise:\n\n  perl -0 -ne '/this/ or next; s/\\0/\\n/g; print'\n\nScott\n-- \nScott Wiersdorf\n<scott@perlcode.org>\n"},{"id":"124487","messageId":"864oq8r795.fsf@blue.stonehenge.com","threadId":"21155","inReplyTo":"vpq1vldx7xx.fsf@bauges.imag.fr","subject":"Re: git log -S not finding all commits?","fromName":"Randal L. Schwartz","fromEmail":"merlyn@stonehenge.com","sentAt":"2009-10-09T14:07:02Z","receivedAt":"2009-10-09T14:07:02Z","isPatch":false,"sender":{"key":"merlyn@stonehenge.com","avatar":"https://gravatar.com/avatar/dc528d210743ff0333e6213f9ee7b33b23f1b7bc1f3c5a8c2d819074ecd7ab19?d=mp&s=160"},"body":">>>>> \"Matthieu\" == Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\nMatthieu> merlyn@stonehenge.com (Randal L. Schwartz) writes:\n>>>>>>> \"Matthieu\" == Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n>> \nMatthieu> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n>>>> git log -p --format=\"%s\\n%x00\"  | perl -0 -ne 'print if(/whatever-you-search/);'\n>> \n>> That \"if\" is noisier than it needs to be:\n>> \n>> perl -0 -ne 'print if /this/'\n\nMatthieu> Also, this seems to actually print the \\0 character. Perhaps a perl\nMatthieu> guru can give a simple solution to replace the \\0 by a \\n?\n\nJust a matter of one more switch.  Sorry for forgetting it earlier.\n\n  .. | perl -ln0e 'print if /this/'\n\nprint \"Just another Perl hacker,\"; # the original\n\n-- \nRandal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095\n<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>\nSmalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.\nSee http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion\n"},{"id":"124493","messageId":"vpq4oq8prse.fsf@bauges.imag.fr","threadId":"21155","inReplyTo":"864oq8r795.fsf@blue.stonehenge.com","subject":"Re: git log -S not finding all commits?","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2009-10-09T14:26:25Z","receivedAt":"2009-10-09T14:26:25Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"merlyn@stonehenge.com (Randal L. Schwartz) writes:\n\n>   .. | perl -ln0e 'print if /this/'\n\nAh, good. I would have done this with 3 lines of code, glad to see a\nsolution with a single more character ;-).\n\nJust updated the FAQ.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"124489","messageId":"86vdioprpf.fsf@blue.stonehenge.com","threadId":"21155","inReplyTo":"vpq4oq8prse.fsf@bauges.imag.fr","subject":"Re: git log -S not finding all commits?","fromName":"Randal L. Schwartz","fromEmail":"merlyn@stonehenge.com","sentAt":"2009-10-09T14:28:12Z","receivedAt":"2009-10-09T14:28:12Z","isPatch":false,"sender":{"key":"merlyn@stonehenge.com","avatar":"https://gravatar.com/avatar/dc528d210743ff0333e6213f9ee7b33b23f1b7bc1f3c5a8c2d819074ecd7ab19?d=mp&s=160"},"body":">>>>> \"Matthieu\" == Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\nMatthieu> merlyn@stonehenge.com (Randal L. Schwartz) writes:\n>> .. | perl -ln0e 'print if /this/'\n\nMatthieu> Ah, good. I would have done this with 3 lines of code, glad to see a\nMatthieu> solution with a single more character ;-).\n\nMatthieu> Just updated the FAQ.\n\nAnd I found that in \"perldoc perlrun\", because I couldn't remember either. :)\n\n-- \nRandal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095\n<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>\nSmalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.\nSee http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion\n"},{"id":"124490","messageId":"20091009143341.GA50862@perlcode.org","threadId":"21155","inReplyTo":"864oq8r795.fsf@blue.stonehenge.com","subject":"Re: git log -S not finding all commits?","fromName":"Scott Wiersdorf","fromEmail":"scott@perlcode.org","sentAt":"2009-10-09T14:33:42Z","receivedAt":"2009-10-09T14:33:42Z","isPatch":false,"sender":{"key":"scott@perlcode.org","avatar":null},"body":"On Fri, Oct 09, 2009 at 07:07:02AM -0700, Randal L. Schwartz wrote:\n> \n> Just a matter of one more switch.  Sorry for forgetting it earlier.\n> \n>   .. | perl -ln0e 'print if /this/'\n\nAnd I thought mine was a pretty tidy response... You *are* Japh.\n\nScott\n-- \nScott Wiersdorf\n<scott@perlcode.org>\n"}]}