{"thread":{"id":"30739","subject":"Getting pickaxe to perform looser matches, or regex matching","startedAt":"2012-06-07T16:43:14Z","lastAt":"2012-06-07T18:48:39Z","messageCount":3,"participants":["Martin Langhoff","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"193076","messageId":"CACPiFCKyhZPQR+e27Ah5THiPPJy3akajGN5xMwBumP-Wj6JrKQ@mail.gmail.com","threadId":"30739","inReplyTo":null,"subject":"Getting pickaxe to perform looser matches, or regex matching","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2012-06-07T16:43:14Z","receivedAt":"2012-06-07T16:43:14Z","isPatch":false,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"I am a regular user of gitk's nice pickaxe search field. But it will often\nfail to find what I am looking for because the part of the string I can\nprovide is not the part that changes.\n\nFor example, I am looking for patches that change any calls to function\nfoo(). I want to match on\n\n- foo(1, 0, 1024)\n+ foo(0, 1024, 1)\n\nbut I don't know the parameters. As the \"pickaxe\" sections in gitdiffcore\nand git log manpages indicate, it won't match on -S'foo' because foo itself\nwas not added or removed.\n\nA regex like \"foo(.*\" would work, but pickaxe doesn't seem to take\nregexes, and while I could roll my own wrapper around git-log --patch,\nthis sounds like an important and useful variant to pickaxe that is\nmissing.\n\nOr that has a hidden switch I haven't found ;-)\n\n\n\nm\n--\n martin.langhoff@gmail.com\n martin@laptop.org -- Software Architect - OLPC\n - ask interesting questions\n - don't get distracted with shiny stuff  - working code first\n - http://wiki.laptop.org/go/User:Martinlanghoff\n"},{"id":"193090","messageId":"7vy5nzgg1h.fsf@alter.siamese.dyndns.org","threadId":"30739","inReplyTo":"CACPiFCKyhZPQR+e27Ah5THiPPJy3akajGN5xMwBumP-Wj6JrKQ@mail.gmail.com","subject":"Re: Getting pickaxe to perform looser matches, or regex matching","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-06-07T17:58:34Z","receivedAt":"2012-06-07T17:58:34Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Langhoff <martin.langhoff@gmail.com> writes:\n\n> I am a regular user of gitk's nice pickaxe search field. But it will often\n> fail to find what I am looking for because the part of the string I can\n> provide is not the part that changes.\n>\n> For example, I am looking for patches that change any calls to function\n> foo(). I want to match on\n>\n> - foo(1, 0, 1024)\n> + foo(0, 1024, 1)\n>\n> but I don't know the parameters. As the \"pickaxe\" sections in gitdiffcore\n> and git log manpages indicate, it won't match on -S'foo' because foo itself\n> was not added or removed.\n>\n> A regex like \"foo(.*\" would work, but pickaxe doesn't seem to take\n> regexes, and while I could roll my own wrapper around git-log --patch,\n> this sounds like an important and useful variant to pickaxe that is\n> missing.\n>\n> Or that has a hidden switch I haven't found ;-)\n\nLike more expensive -G that was recently added?\n"},{"id":"193098","messageId":"CACPiFCJHY4vfrrWRm_cC2Ck6RAyQosWwqijxPbs+Fn0T_AoT1w@mail.gmail.com","threadId":"30739","inReplyTo":"7vy5nzgg1h.fsf@alter.siamese.dyndns.org","subject":"Re: Getting pickaxe to perform looser matches, or regex matching","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2012-06-07T18:48:39Z","receivedAt":"2012-06-07T18:48:39Z","isPatch":false,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On Thu, Jun 7, 2012 at 1:58 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Like more expensive -G that was recently added?\n\nYay! That does what I wanted, though the manpage relies on subtle\nwording to convey it. You have to read -S and -G twice and think about\nit. It would be much better to say something like \"If -S isn't finding\nwhat you need, try -G and you shall find it\" -- AFAICT it is true for\nthe common cases.\n\ngitk doesn't seem to know how to use it. Attached is a trivial patch\n(apologies about attaching it, in lieu of proper list style). Simple,\nand works for me.\n\nWhile I am not learned in gitk internal structure, it seems complete.\nMy only doubt is whether any additional work is needed under set\nknown_view_options {}. I cannot quite fathom that part of gitk. Review\nwelcome.\n\ncheers,\n\n\n\nm\n-- \n martin.langhoff@gmail.com\n martin@laptop.org -- Software Architect - OLPC\n - ask interesting questions\n - don't get distracted with shiny stuff  - working code first\n - http://wiki.laptop.org/go/User:Martinlanghoff\n\n\nFrom d86137c8c2f2ac42b030a0e0b40c59c6029ccd4f Mon Sep 17 00:00:00 2001\nFrom: Martin Langhoff <martin@laptop.org>\nDate: Thu, 7 Jun 2012 14:41:58 -0400\nSubject: [PATCH] gitk: add support for -G'regex' pickaxe variant\n\ngit log -G'regex' is a very usable alternative to the classic\npickaxe. Minimal patch to make it usable from gitk.\n---\n gitk-git/gitk |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nindex 22270ce..876b8f9 100755\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -2232,7 +2232,8 @@ proc makewindow {} {\n     set gm [makedroplist .tf.lbar.gdttype gdttype \\\n \t\t[mc \"containing:\"] \\\n \t\t[mc \"touching paths:\"] \\\n-\t\t[mc \"adding/removing string:\"]]\n+\t\t[mc \"adding/removing string:\"] \\\n+\t\t[mc \"changes match regex:\"]]\n     trace add variable gdttype write gdttype_change\n     pack .tf.lbar.gdttype -side left -fill y\n \n@@ -4595,6 +4596,8 @@ proc do_file_hl {serial} {\n \tset gdtargs [concat -- $relative_paths]\n     } elseif {$gdttype eq [mc \"adding/removing string:\"]} {\n \tset gdtargs [list \"-S$highlight_files\"]\n+    } elseif {$gdttype eq [mc \"changes match regex:\"]} {\n+\tset gdtargs [list \"-G$highlight_files\"]\n     } else {\n \t# must be \"containing:\", i.e. we're searching commit info\n \treturn\n-- \n1.7.7.6\n\n"}]}