<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/grep.c, branch v2.9.3</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.9.3</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.9.3'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2016-08-10T18:55:29Z</updated>
<entry>
<title>Merge branch 'jc/grep-commandline-vs-configuration' into maint</title>
<updated>2016-08-10T18:55:29Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2016-08-10T18:55:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7b163e918772736b69252053913ba5ccc24adb4d'/>
<id>urn:sha1:7b163e918772736b69252053913ba5ccc24adb4d</id>
<content type='text'>
"git -c grep.patternType=extended log --basic-regexp" misbehaved
because the internal API to access the grep machinery was not
designed well.

* jc/grep-commandline-vs-configuration:
  grep: further simplify setting the pattern type
</content>
</entry>
<entry>
<title>Merge branch 'nd/icase' into maint</title>
<updated>2016-07-28T18:26:03Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2016-07-28T18:26:03Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6cbec0da471590a2b3de1b98795ba20f274d53fa'/>
<id>urn:sha1:6cbec0da471590a2b3de1b98795ba20f274d53fa</id>
<content type='text'>
"git grep -i" has been taught to fold case in non-ascii locales
correctly.

* nd/icase:
  grep.c: reuse "icase" variable
  diffcore-pickaxe: support case insensitive match on non-ascii
  diffcore-pickaxe: Add regcomp_or_die()
  grep/pcre: support utf-8
  gettext: add is_utf8_locale()
  grep/pcre: prepare locale-dependent tables for icase matching
  grep: rewrite an if/else condition to avoid duplicate expression
  grep/icase: avoid kwsset when -F is specified
  grep/icase: avoid kwsset on literal non-ascii strings
  test-regex: expose full regcomp() to the command line
  test-regex: isolate the bug test code
  grep: break down an "if" stmt in preparation for next changes
</content>
</entry>
<entry>
<title>grep: further simplify setting the pattern type</title>
<updated>2016-07-25T16:16:18Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2016-07-22T18:43:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8465541e8ce8eaf16e66ab847086779768c18f2d'/>
<id>urn:sha1:8465541e8ce8eaf16e66ab847086779768c18f2d</id>
<content type='text'>
When c5c31d33 (grep: move pattern-type bits support to top-level
grep.[ch], 2012-10-03) introduced grep_commit_pattern_type() helper
function, the intention was to allow the users of grep API to having
to fiddle only with .pattern_type_option (which can be set to "fixed",
"basic", "extended", and "pcre"), and then immediately before compiling
the pattern strings for use, call grep_commit_pattern_type() to have
it prepare various bits in the grep_opt structure (like .fixed,
.regflags, etc.).

However, grep_set_pattern_type_option() helper function the grep API
internally uses were left as an external function by mistake.  This
function shouldn't have been made callable by the users of the API.

Later when the grep API was used in revision traversal machinery,
the caller then mistakenly started calling the function around
34a4ae55 (log --grep: use the same helper to set -E/-F options as
"git grep", 2012-10-03), instead of setting the .pattern_type_option
field and letting the grep_commit_pattern_type() to take care of the
details.

This caused an unnecessary bug that made a configured
grep.patternType take precedence over the command line options
(e.g. --basic-regexp, --fixed-strings) in "git log" family of
commands.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>grep.c: reuse "icase" variable</title>
<updated>2016-07-01T19:44:57Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2016-06-25T05:22:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=695f95ba5dc4ab44f327574f85c3ebe7ebf449b1'/>
<id>urn:sha1:695f95ba5dc4ab44f327574f85c3ebe7ebf449b1</id>
<content type='text'>
Signed-off-by: Nguyễn Thái Ngọc Duy &lt;pclouds@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>grep/pcre: support utf-8</title>
<updated>2016-07-01T19:44:57Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2016-06-25T05:22:35Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=18547aacf5ced88bf83d85b03b2b7b3fc6aa3f6c'/>
<id>urn:sha1:18547aacf5ced88bf83d85b03b2b7b3fc6aa3f6c</id>
<content type='text'>
In the previous change in this function, we add locale support for
single-byte encodings only. It looks like pcre only supports utf-* as
multibyte encodings, the others are left in the cold (which is
fine).

We need to enable PCRE_UTF8 so pcre can find character boundary
correctly. It's needed for case folding (when --ignore-case is used)
or '*', '+' or similar syntax is used.

The "has_non_ascii()" check is to be on the conservative side. If
there's non-ascii in the pattern, the searched content could still be
in utf-8, but we can treat it just like a byte stream and everything
should work. If we force utf-8 based on locale only and pcre validates
utf-8 and the file content is in non-utf8 encoding, things break.

Noticed-by: Plamen Totev &lt;plamen.totev@abv.bg&gt;
Helped-by: Plamen Totev &lt;plamen.totev@abv.bg&gt;
Signed-off-by: Nguyễn Thái Ngọc Duy &lt;pclouds@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>grep/pcre: prepare locale-dependent tables for icase matching</title>
<updated>2016-07-01T19:44:57Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2016-06-25T05:22:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9d9babb84d45234132f3cb1f4527ce1106e3d2ec'/>
<id>urn:sha1:9d9babb84d45234132f3cb1f4527ce1106e3d2ec</id>
<content type='text'>
The default tables are usually built with C locale and only suitable
for LANG=C or similar.  This should make case insensitive search work
correctly for all single-byte charsets.

Signed-off-by: Nguyễn Thái Ngọc Duy &lt;pclouds@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>grep: rewrite an if/else condition to avoid duplicate expression</title>
<updated>2016-07-01T19:44:57Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2016-06-25T05:22:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e944d9d932b3653debcfdd16eec2721eed0670e5'/>
<id>urn:sha1:e944d9d932b3653debcfdd16eec2721eed0670e5</id>
<content type='text'>
"!icase || ascii_only" is repeated twice in this if/else chain as this
series evolves. Rewrite it (and basically revert the first if
condition back to before the "grep: break down an "if" stmt..." commit).

Helped-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Signed-off-by: Nguyễn Thái Ngọc Duy &lt;pclouds@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>grep/icase: avoid kwsset when -F is specified</title>
<updated>2016-07-01T19:44:30Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2016-06-25T05:22:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=793dc676e08394ed15bffe0ed66606ff9ced1c6a'/>
<id>urn:sha1:793dc676e08394ed15bffe0ed66606ff9ced1c6a</id>
<content type='text'>
Similar to the previous commit, we can't use kws on icase search
outside ascii range. But we can't simply pass the pattern to
regcomp/pcre like the previous commit because it may contain regex
special characters, so we need to quote the regex first.

To avoid misquote traps that could lead to undefined behavior, we
always stick to basic regex engine in this case. We don't need fancy
features for grepping a literal string anyway.

basic_regex_quote_buf() assumes that if the pattern is in a multibyte
encoding, ascii chars must be unambiguously encoded as single
bytes. This is true at least for UTF-8. For others, let's wait until
people yell up. Chances are nobody uses multibyte, non utf-8 charsets
anymore.

Noticed-by: Plamen Totev &lt;plamen.totev@abv.bg&gt;
Helped-by: René Scharfe &lt;l.s.r@web.de&gt;
Helped-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Signed-off-by: Nguyễn Thái Ngọc Duy &lt;pclouds@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'rs/xdiff-hunk-with-func-line' into maint</title>
<updated>2016-06-27T16:56:24Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2016-06-27T16:56:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=fda65fadb6e98b5b8ea8058bbeaa29d983f335cb'/>
<id>urn:sha1:fda65fadb6e98b5b8ea8058bbeaa29d983f335cb</id>
<content type='text'>
"git show -W" (extend hunks to cover the entire function, delimited
by lines that match the "funcname" pattern) used to show the entire
file when a change added an entire function at the end of the file,
which has been fixed.

* rs/xdiff-hunk-with-func-line:
  xdiff: fix merging of appended hunk with -W
  grep: -W: don't extend context to trailing empty lines
  t7810: add test for grep -W and trailing empty context lines
  xdiff: don't trim common tail with -W
  xdiff: -W: don't include common trailing empty lines in context
  xdiff: ignore empty lines before added functions with -W
  xdiff: handle appended chunks better with -W
  xdiff: factor out match_func_rec()
  t4051: rewrite, add more tests
</content>
</entry>
<entry>
<title>grep/icase: avoid kwsset on literal non-ascii strings</title>
<updated>2016-06-27T14:31:35Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2016-06-25T05:22:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5c1ebcca4d1df3b2a84d01b3f32ec13bf8f760f8'/>
<id>urn:sha1:5c1ebcca4d1df3b2a84d01b3f32ec13bf8f760f8</id>
<content type='text'>
When we detect the pattern is just a literal string, we avoid heavy
regex engine and use fast substring search implemented in kwsset.c.
But kws uses git-ctype which is locale-independent so it does not know
how to fold case properly outside ascii range. Let regcomp or pcre
take care of this case instead. Slower, but accurate.

Noticed-by: Plamen Totev &lt;plamen.totev@abv.bg&gt;
Helped-by: René Scharfe &lt;l.s.r@web.de&gt;
Helped-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Signed-off-by: Nguyễn Thái Ngọc Duy &lt;pclouds@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
