git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Getting pickaxe to perform looser matches, or regex matching
@ 2012-06-07 16:43 Martin Langhoff
  2012-06-07 17:58 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Langhoff @ 2012-06-07 16:43 UTC (permalink / raw)
  To: Git Mailing List

I am a regular user of gitk's nice pickaxe search field. But it will often
fail to find what I am looking for because the part of the string I can
provide is not the part that changes.

For example, I am looking for patches that change any calls to function
foo(). I want to match on

- foo(1, 0, 1024)
+ foo(0, 1024, 1)

but I don't know the parameters. As the "pickaxe" sections in gitdiffcore
and git log manpages indicate, it won't match on -S'foo' because foo itself
was not added or removed.

A regex like "foo(.*" would work, but pickaxe doesn't seem to take
regexes, and while I could roll my own wrapper around git-log --patch,
this sounds like an important and useful variant to pickaxe that is
missing.

Or that has a hidden switch I haven't found ;-)



m
--
 martin.langhoff@gmail.com
 martin@laptop.org -- Software Architect - OLPC
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Getting pickaxe to perform looser matches, or regex matching
  2012-06-07 16:43 Getting pickaxe to perform looser matches, or regex matching Martin Langhoff
@ 2012-06-07 17:58 ` Junio C Hamano
  2012-06-07 18:48   ` Martin Langhoff
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2012-06-07 17:58 UTC (permalink / raw)
  To: Martin Langhoff; +Cc: git

Martin Langhoff <martin.langhoff@gmail.com> writes:

> I am a regular user of gitk's nice pickaxe search field. But it will often
> fail to find what I am looking for because the part of the string I can
> provide is not the part that changes.
>
> For example, I am looking for patches that change any calls to function
> foo(). I want to match on
>
> - foo(1, 0, 1024)
> + foo(0, 1024, 1)
>
> but I don't know the parameters. As the "pickaxe" sections in gitdiffcore
> and git log manpages indicate, it won't match on -S'foo' because foo itself
> was not added or removed.
>
> A regex like "foo(.*" would work, but pickaxe doesn't seem to take
> regexes, and while I could roll my own wrapper around git-log --patch,
> this sounds like an important and useful variant to pickaxe that is
> missing.
>
> Or that has a hidden switch I haven't found ;-)

Like more expensive -G that was recently added?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Getting pickaxe to perform looser matches, or regex matching
  2012-06-07 17:58 ` Junio C Hamano
@ 2012-06-07 18:48   ` Martin Langhoff
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Langhoff @ 2012-06-07 18:48 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 1058 bytes --]

On Thu, Jun 7, 2012 at 1:58 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Like more expensive -G that was recently added?

Yay! That does what I wanted, though the manpage relies on subtle
wording to convey it. You have to read -S and -G twice and think about
it. It would be much better to say something like "If -S isn't finding
what you need, try -G and you shall find it" -- AFAICT it is true for
the common cases.

gitk doesn't seem to know how to use it. Attached is a trivial patch
(apologies about attaching it, in lieu of proper list style). Simple,
and works for me.

While I am not learned in gitk internal structure, it seems complete.
My only doubt is whether any additional work is needed under set
known_view_options {}. I cannot quite fathom that part of gitk. Review
welcome.

cheers,



m
-- 
 martin.langhoff@gmail.com
 martin@laptop.org -- Software Architect - OLPC
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff

[-- Attachment #2: 0001-gitk-add-support-for-G-regex-pickaxe-variant.patch --]
[-- Type: application/octet-stream, Size: 1268 bytes --]

From d86137c8c2f2ac42b030a0e0b40c59c6029ccd4f Mon Sep 17 00:00:00 2001
From: Martin Langhoff <martin@laptop.org>
Date: Thu, 7 Jun 2012 14:41:58 -0400
Subject: [PATCH] gitk: add support for -G'regex' pickaxe variant

git log -G'regex' is a very usable alternative to the classic
pickaxe. Minimal patch to make it usable from gitk.
---
 gitk-git/gitk |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index 22270ce..876b8f9 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -2232,7 +2232,8 @@ proc makewindow {} {
     set gm [makedroplist .tf.lbar.gdttype gdttype \
 		[mc "containing:"] \
 		[mc "touching paths:"] \
-		[mc "adding/removing string:"]]
+		[mc "adding/removing string:"] \
+		[mc "changes match regex:"]]
     trace add variable gdttype write gdttype_change
     pack .tf.lbar.gdttype -side left -fill y
 
@@ -4595,6 +4596,8 @@ proc do_file_hl {serial} {
 	set gdtargs [concat -- $relative_paths]
     } elseif {$gdttype eq [mc "adding/removing string:"]} {
 	set gdtargs [list "-S$highlight_files"]
+    } elseif {$gdttype eq [mc "changes match regex:"]} {
+	set gdtargs [list "-G$highlight_files"]
     } else {
 	# must be "containing:", i.e. we're searching commit info
 	return
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-06-07 18:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-07 16:43 Getting pickaxe to perform looser matches, or regex matching Martin Langhoff
2012-06-07 17:58 ` Junio C Hamano
2012-06-07 18:48   ` Martin Langhoff

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).