<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/git-grep.sh, branch v1.2.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v1.2.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v1.2.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2006-01-22T03:34:11Z</updated>
<entry>
<title>git-grep: clarification on parameters.</title>
<updated>2006-01-22T03:34:11Z</updated>
<author>
<name>Junio C Hamano</name>
<email>junkio@cox.net</email>
</author>
<published>2006-01-20T23:00:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5b2bcc7b2d546c636f79490655b3347acc91d17f'/>
<id>urn:sha1:5b2bcc7b2d546c636f79490655b3347acc91d17f</id>
<content type='text'>
We forgot to make sure that there is no more than one pattern
parameter.  Also when looking for files in a directory called
'--others', it passed that path limiter without preceding the
end-of-options marker '--' to underlying git-ls-files, which
misunderstood it as one of its options instead.

	$ git grep --others -e Meta/Make Meta
	$ git grep -o -e Meta/Make Meta
	$ git grep -o Meta/Make Meta

look for a string "Meta/Make" from untracked files in Meta/
directory.

	$ git grep Meta/Make --others

looks for the same string from tracked files in ./--others
directory.

On the other hand,

	$ git grep -e Meta/Make --others

does not have a freestanding pattern, so everybody is parameter
and there is no path specifier.  It looks for the string in all
the untracked files without any path limiter.

[jc: updated with usability enhancements and documentation
cleanups from Sean.]

Signed-off-by: Junio C Hamano &lt;junkio@cox.net&gt;
</content>
</entry>
<entry>
<title>Trivial usage string clean-up</title>
<updated>2005-12-14T10:53:43Z</updated>
<author>
<name>freku045@student.liu.se</name>
<email>freku045@student.liu.se</email>
</author>
<published>2005-12-13T22:30:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=806f36d4d7caf75b6d3e098cb0353d85d3477c7d'/>
<id>urn:sha1:806f36d4d7caf75b6d3e098cb0353d85d3477c7d</id>
<content type='text'>
Signed-off-by: Fredrik Kuivinen &lt;freku045@student.liu.se&gt;
Signed-off-by: Junio C Hamano &lt;junkio@cox.net&gt;
</content>
</entry>
<entry>
<title>Disallow empty pattern in "git grep"</title>
<updated>2005-11-16T21:17:46Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@osdl.org</email>
</author>
<published>2005-11-16T17:38:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c0c35d5e419f3bf215103b1e26359aca288c2113'/>
<id>urn:sha1:c0c35d5e419f3bf215103b1e26359aca288c2113</id>
<content type='text'>
For some reason I've done a "git grep" twice with no pattern, which is
really irritating, since it just grep everything. If I actually wanted
that, I could do "git grep ^" or something.

So add a "usage" message if the pattern is empty.

Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
Signed-off-by: Junio C Hamano &lt;junkio@cox.net&gt;
</content>
</entry>
<entry>
<title>git-grep: fix 'git grep -e $pattern' handling</title>
<updated>2005-09-24T22:09:48Z</updated>
<author>
<name>Junio C Hamano</name>
<email>junkio@cox.net</email>
</author>
<published>2005-09-24T22:09:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c9fc748f84857a237f47deb91f87499e82865c83'/>
<id>urn:sha1:c9fc748f84857a237f47deb91f87499e82865c83</id>
<content type='text'>
People typically say 'grep -e $pattern' because $pattern has a leading
dash which would be mistaken as a grep flag.  Make sure we pass -e in
front of $pattern when we invoke grep.

Signed-off-by: Junio C Hamano &lt;junkio@cox.net&gt;
</content>
</entry>
<entry>
<title>Improve "git grep" flags handling</title>
<updated>2005-09-13T02:15:02Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@osdl.org</email>
</author>
<published>2005-09-12T23:46:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5d9d831a51dc7847ad40fac77f9a072aa2d1c0bd'/>
<id>urn:sha1:5d9d831a51dc7847ad40fac77f9a072aa2d1c0bd</id>
<content type='text'>
This allows any arbitrary flags to "grep", and knows about the few
special grep flags that take an argument too.

It also allows some flags for git-ls-files, although their usefulness
is questionable.

With this, something line

	git grep -w -1 pattern

works, without the script enumerating every possible flag.

[jc: this is the version Linus sent out after I showed him a
 barf-o-meter test version that avoids shell arrays.  He must
 have typed this version blindly, since he said:

    I'm not barfing, but that's probably because my brain just shut
    down and is desperately trying to gouge my eyes out with a spoon.

 I slightly fixed it to catch the remaining arguments meant to be
 given git-ls-files.]

Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
Signed-off-by: Junio C Hamano &lt;junkio@cox.net&gt;
</content>
</entry>
<entry>
<title>Allow finding things that begin with a dash in 'git grep'</title>
<updated>2005-09-12T20:24:55Z</updated>
<author>
<name>Junio C Hamano</name>
<email>junkio@cox.net</email>
</author>
<published>2005-09-12T20:24:55Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=540bf654d007b3289adec37e3008c588ba677e25'/>
<id>urn:sha1:540bf654d007b3289adec37e3008c588ba677e25</id>
<content type='text'>
Signed-off-by: Junio C Hamano &lt;junkio@cox.net&gt;
</content>
</entry>
<entry>
<title>[PATCH] Add "git grep" helper</title>
<updated>2005-09-12T20:20:03Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@osdl.org</email>
</author>
<published>2005-09-12T19:06:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f22cc3fcbfe7755154a3a151215abd39162e2e85'/>
<id>urn:sha1:f22cc3fcbfe7755154a3a151215abd39162e2e85</id>
<content type='text'>
Very convenient shorthand for

	git-ls-files [file-patterns] | xargs grep &lt;pattern&gt;

which I tend to do all the time.

Yes, it's trivial, but it's really nice. I can do

	git grep '\&lt;some_variable\&gt;' arch/i386 include/asm-i386

and it does exactly what you'd think it does. And since it just uses the
normal git-ls-files file patterns, you can do things like

	git grep something 'include/*.h'

and it will search all header files under the include/ subdirectory.

Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
Signed-off-by: Junio C Hamano &lt;junkio@cox.net&gt;
</content>
</entry>
</feed>
