<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/grep.c, branch v1.6.4</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v1.6.4</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v1.6.4'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2009-07-03T04:36:42Z</updated>
<entry>
<title>grep: simplify -p output</title>
<updated>2009-07-03T04:36:42Z</updated>
<author>
<name>René Scharfe</name>
<email>rene.scharfe@lsrfire.ath.cx</email>
</author>
<published>2009-07-01T22:06:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ed24e401e0e6ab860475b8575e28a2c6ea99cc69'/>
<id>urn:sha1:ed24e401e0e6ab860475b8575e28a2c6ea99cc69</id>
<content type='text'>
It was found a bit too loud to show == separators between the function
headers.

Signed-off-by: Rene Scharfe &lt;rene.scharfe@lsrfire.ath.cx&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>grep -p: support user defined regular expressions</title>
<updated>2009-07-02T02:16:50Z</updated>
<author>
<name>René Scharfe</name>
<email>rene.scharfe@lsrfire.ath.cx</email>
</author>
<published>2009-07-01T22:07:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=60ecac98ed6f420c6bf823491074219087c749d4'/>
<id>urn:sha1:60ecac98ed6f420c6bf823491074219087c749d4</id>
<content type='text'>
Respect the userdiff attributes and config settings when looking for
lines with function definitions in git grep -p.

Signed-off-by: Rene Scharfe &lt;rene.scharfe@lsrfire.ath.cx&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>grep: add option -p/--show-function</title>
<updated>2009-07-02T02:16:49Z</updated>
<author>
<name>René Scharfe</name>
<email>rene.scharfe@lsrfire.ath.cx</email>
</author>
<published>2009-07-01T22:06:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2944e4e6145bdfcb1a8730d7da671786d72c86ed'/>
<id>urn:sha1:2944e4e6145bdfcb1a8730d7da671786d72c86ed</id>
<content type='text'>
The new option -p instructs git grep to print the previous function
definition as a context line, similar to diff -p.  Such context lines
are marked with an equal sign instead of a dash.  This option
complements the existing context options -A, -B, -C.

Function definitions are detected using the same heuristic that diff
uses.  User defined regular expressions are not supported, yet.

Signed-off-by: Rene Scharfe &lt;rene.scharfe@lsrfire.ath.cx&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>grep: handle pre context lines on demand</title>
<updated>2009-07-02T02:16:48Z</updated>
<author>
<name>René Scharfe</name>
<email>rene.scharfe@lsrfire.ath.cx</email>
</author>
<published>2009-07-01T22:05:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=49de3216983cc921ea66ade18a8521d4d74bbf3f'/>
<id>urn:sha1:49de3216983cc921ea66ade18a8521d4d74bbf3f</id>
<content type='text'>
Factor out pre context line handling into the new function
show_pre_context() and change the algorithm to rewind by looking for
newline characters and roll forward again, instead of maintaining an
array of line beginnings and ends.

This is slower for hits, but the cost for non-matching lines becomes
zero.  Normally, there are far more non-matching lines, so the time
spent in total decreases.

Before this patch (current Linux kernel repo, best of five runs):

	$ time git grep --no-ext-grep -B1 memset &gt;/dev/null

	real	0m2.134s
	user	0m1.932s
	sys	0m0.196s

	$ time git grep --no-ext-grep -B1000 memset &gt;/dev/null

	real	0m12.059s
	user	0m11.837s
	sys	0m0.224s

The same with this patch:

	$ time git grep --no-ext-grep -B1 memset &gt;/dev/null

	real	0m2.117s
	user	0m1.892s
	sys	0m0.228s

	$ time git grep --no-ext-grep -B1000 memset &gt;/dev/null

	real	0m2.986s
	user	0m2.696s
	sys	0m0.288s

Signed-off-by: Rene Scharfe &lt;rene.scharfe@lsrfire.ath.cx&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>grep: print context hunk marks between files</title>
<updated>2009-07-02T02:16:46Z</updated>
<author>
<name>René Scharfe</name>
<email>rene.scharfe@lsrfire.ath.cx</email>
</author>
<published>2009-07-01T22:03:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=046802d015b3be2e055ae68f29f76741023bc32d'/>
<id>urn:sha1:046802d015b3be2e055ae68f29f76741023bc32d</id>
<content type='text'>
Print a hunk mark before matches from a new file are shown, in addition
to the current behaviour of printing them if lines have been skipped.

The result is easier to read, as (presumably unrelated) matches from
different files are separated by a hunk mark.  GNU grep does the same.

Signed-off-by: Rene Scharfe &lt;rene.scharfe@lsrfire.ath.cx&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>grep: move context hunk mark handling into show_line()</title>
<updated>2009-07-02T02:16:45Z</updated>
<author>
<name>René Scharfe</name>
<email>rene.scharfe@lsrfire.ath.cx</email>
</author>
<published>2009-07-01T22:02:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5dd06d38795b2f6d05f851b25c814732238f8df1'/>
<id>urn:sha1:5dd06d38795b2f6d05f851b25c814732238f8df1</id>
<content type='text'>
Move last_shown into struct grep_opt, to make it available in
show_line(), and then make the function handle the printing of hunk
marks for context lines in a central place.

Signed-off-by: Rene Scharfe &lt;rene.scharfe@lsrfire.ath.cx&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>grep: fix empty word-regexp matches</title>
<updated>2009-06-03T18:32:29Z</updated>
<author>
<name>René Scharfe</name>
<email>rene.scharfe@lsrfire.ath.cx</email>
</author>
<published>2009-06-03T16:19:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=84201eae771fbb1d774cf1356d89016053e56778'/>
<id>urn:sha1:84201eae771fbb1d774cf1356d89016053e56778</id>
<content type='text'>
The command "git grep -w ''" dies as soon as it encounters an empty line,
reporting (wrongly) that "regexp returned nonsense".  The first hunk of
this patch relaxes the sanity check that is responsible for that,
allowing matches to start at the end.

The second hunk complements it by making sure that empty matches are
rejected if -w was specified, as they are not really words.

GNU grep does the same:

	$ echo foo | grep -c ''
	1
	$ echo foo | grep -c -w ''
	0

Signed-off-by: Rene Scharfe &lt;rene.scharfe@lsrfire.ath.cx&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>grep: fix colouring of matches with zero length</title>
<updated>2009-06-02T05:30:39Z</updated>
<author>
<name>René Scharfe</name>
<email>rene.scharfe@lsrfire.ath.cx</email>
</author>
<published>2009-06-01T21:53:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1f5b9cc40e80a8a7902236a26844be138887b1d9'/>
<id>urn:sha1:1f5b9cc40e80a8a7902236a26844be138887b1d9</id>
<content type='text'>
If a zero-length match is encountered, break out of loop and show the rest
of the line uncoloured.  Otherwise we'd be looping forever, trying to make
progress by advancing the pointer by zero characters.

Signed-off-by: Rene Scharfe &lt;rene.scharfe@lsrfire.ath.cx&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>grep: fix word-regexp at the beginning of lines</title>
<updated>2009-05-23T23:29:05Z</updated>
<author>
<name>René Scharfe</name>
<email>rene.scharfe@lsrfire.ath.cx</email>
</author>
<published>2009-05-23T11:45:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=dbb6a4ada6c6c1065b62313127ff032196e9d232'/>
<id>urn:sha1:dbb6a4ada6c6c1065b62313127ff032196e9d232</id>
<content type='text'>
After bol is forwarded, it doesn't represent the beginning of the line
any more.  This means that the beginning-of-line marker (^) mustn't match,
i.e. the regex flag REG_NOTBOL needs to be set.

This bug was introduced by fb62eb7fab97cea880ea7fe4f341a4dfad14ab48
("grep -w: forward to next possible position after rejected match").

Signed-off-by: Rene Scharfe &lt;rene.scharfe@lsrfire.ath.cx&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>grep: fix word-regexp colouring</title>
<updated>2009-05-21T01:49:20Z</updated>
<author>
<name>René Scharfe</name>
<email>rene.scharfe@lsrfire.ath.cx</email>
</author>
<published>2009-05-20T21:31:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e701fadb9e0e51a6811690d95a53bd1f5b6fad86'/>
<id>urn:sha1:e701fadb9e0e51a6811690d95a53bd1f5b6fad86</id>
<content type='text'>
As noticed by Dmitry Gryazin: When a pattern is found but it doesn't
start and end at word boundaries, bol is forwarded to after the match and
the pattern is searched again.  When a pattern is finally found between
word boundaries, the match offsets are off by the number of characters
that have been skipped.

This patch corrects the offsets to be relative to the value of bol as
passed to match_one_pattern() by its caller.

Signed-off-by: Rene Scharfe &lt;rene.scharfe@lsrfire.ath.cx&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
