gitk: add "grep diff" selection criterion (Re: find commit adding/removing could use changing option)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Chris,

Chris Smith wrote:

> One thing I find myself wishing for is the ability to find a line that has
> been modified by using gitk. It seems to me that if I have the following in a
> diff
> 
> - def foo(this)
> + def foo(this, that=False)
> 
> that I can't find the line by searching for foo.

Ah, so you want a cousin to ‘log -S’ that /does/ search through
diffs.  See [1].

As that thread explains, it is doable from the commandline already,
though not in a nicely packaged form.  But what about from gitk?

A possible hack would be to teach gitk to add arbitrary criteria to
the end of the ‘git diff-tree’ command line[2].  In this case, the
criterion would be ‘| search-diff $term’, where search-diff is a
script something like the following:

 #!/bin/sh
 while read -r commit
 do
	if
		git diff-tree -p -c "$commit" | grep -q "$@"
	then
		printf '%s\n' "$commit"
	fi
 done

If that proves useful, afterwards one could teach ‘diff-tree’ to do
the check itself, which would allow commands like

 git log --search-diff=foo

too.

Thoughts?
Jonathan

[1] http://thread.gmane.org/gmane.comp.version-control.git/122478
[2] You can find the code one would need to touch for this by
searching for gdtargs and gdttype in the gitk script.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]