<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/grep.c, branch v2.18.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.18.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.18.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2018-05-30T12:51:28Z</updated>
<entry>
<title>Merge branch 'ma/regex-no-regfree-after-comp-fail'</title>
<updated>2018-05-30T12:51:28Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2018-05-30T12:51:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d89f1248aaf4bb5d1094bc991a50839411935cf6'/>
<id>urn:sha1:d89f1248aaf4bb5d1094bc991a50839411935cf6</id>
<content type='text'>
We used to call regfree() after regcomp() failed in some codepaths,
which have been corrected.

* ma/regex-no-regfree-after-comp-fail:
  regex: do not call `regfree()` if compilation fails
</content>
</entry>
<entry>
<title>regex: do not call `regfree()` if compilation fails</title>
<updated>2018-05-21T04:58:32Z</updated>
<author>
<name>Martin Ågren</name>
<email>martin.agren@gmail.com</email>
</author>
<published>2018-05-20T10:50:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=17154b1576f8be5aa3044f3adadb5473da618a42'/>
<id>urn:sha1:17154b1576f8be5aa3044f3adadb5473da618a42</id>
<content type='text'>
It is apparently undefined behavior to call `regfree()` on a regex where
`regcomp()` failed. The language in [1] is a bit muddy, at least to me,
but the clearest hint is this (`preg` is the `regex_t *`):

    Upon successful completion, the regcomp() function shall return 0.
    Otherwise, it shall return an integer value indicating an error as
    described in &lt;regex.h&gt;, and the content of preg is undefined.

Funnily enough, there is also the `regerror()` function which should be
given a pointer to such a "failed" `regex_t` -- the content of which
would supposedly be undefined -- and which may investigate it to come up
with a detailed error message.

In any case, the example in that document shows how `regfree()` is not
called after `regcomp()` fails.

We have quite a few users of this API and most get this right. These
three users do not.

Several implementations can handle this just fine [2] and these code paths
supposedly have not wreaked havoc or we'd have heard about it. (These
are all in code paths where git got bad input and is just about to die
anyway.) But let's just avoid the issue altogether.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/regcomp.html

[2] https://www.redhat.com/archives/libvir-list/2013-September/msg00262.html

Researched-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Signed-off-byi Martin Ågren &lt;martin.agren@gmail.com&gt;

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Replace all die("BUG: ...") calls by BUG() ones</title>
<updated>2018-05-06T10:06:13Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2018-05-02T09:38:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=033abf97fcbc247eabf915780181d947cfb66205'/>
<id>urn:sha1:033abf97fcbc247eabf915780181d947cfb66205</id>
<content type='text'>
In d8193743e08 (usage.c: add BUG() function, 2017-05-12), a new macro
was introduced to use for reporting bugs instead of die(). It was then
subsequently used to convert one single caller in 588a538ae55
(setup_git_env: convert die("BUG") to BUG(), 2017-05-12).

The cover letter of the patch series containing this patch
(cf 20170513032414.mfrwabt4hovujde2@sigill.intra.peff.net) is not
terribly clear why only one call site was converted, or what the plan
is for other, similar calls to die() to report bugs.

Let's just convert all remaining ones in one fell swoop.

This trick was performed by this invocation:

	sed -i 's/die("BUG: /BUG("/g' $(git grep -l 'die("BUG' \*.c)

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>sha1_file: convert read_sha1_file to struct object_id</title>
<updated>2018-03-14T16:23:50Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2018-03-12T02:27:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b4f5aca40e6f77cbabcbf4ff003c3cf30a1830c8'/>
<id>urn:sha1:b4f5aca40e6f77cbabcbf4ff003c3cf30a1830c8</id>
<content type='text'>
Convert read_sha1_file to take a pointer to struct object_id and rename
it read_object_file.  Do the same for read_sha1_file_extended.

Convert one use in grep.c to use the new function without any other code
change, since the pointer being passed is a void pointer that is already
initialized with a pointer to struct object_id.  Update the declaration
and definitions of the modified functions, and apply the following
semantic patch to convert the remaining callers:

@@
expression E1, E2, E3;
@@
- read_sha1_file(E1.hash, E2, E3)
+ read_object_file(&amp;E1, E2, E3)

@@
expression E1, E2, E3;
@@
- read_sha1_file(E1-&gt;hash, E2, E3)
+ read_object_file(E1, E2, E3)

@@
expression E1, E2, E3, E4;
@@
- read_sha1_file_extended(E1.hash, E2, E3, E4)
+ read_object_file_extended(&amp;E1, E2, E3, E4)

@@
expression E1, E2, E3, E4;
@@
- read_sha1_file_extended(E1-&gt;hash, E2, E3, E4)
+ read_object_file_extended(E1, E2, E3, E4)

Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>color.h: document and modernize header</title>
<updated>2018-02-13T18:17:12Z</updated>
<author>
<name>Stefan Beller</name>
<email>sbeller@google.com</email>
</author>
<published>2018-02-13T01:41:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=75e5e9c3f7f9615ae2ee38a839aafbbe642a735a'/>
<id>urn:sha1:75e5e9c3f7f9615ae2ee38a839aafbbe642a735a</id>
<content type='text'>
Add documentation explaining the functions in color.h.
While at it, migrate the function `color_set` into grep.c,
where the only callers are.

Signed-off-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'ab/pcre2-grep'</title>
<updated>2017-12-13T21:28:54Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-12-13T21:28:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b3f04e5b4c7e04d70e4cef74b4848dd198653cbb'/>
<id>urn:sha1:b3f04e5b4c7e04d70e4cef74b4848dd198653cbb</id>
<content type='text'>
"git grep" compiled with libpcre2 sometimes triggered a segfault,
which is being fixed.

* ab/pcre2-grep:
  grep: fix segfault under -P + PCRE2 &lt;=10.30 + (*NO_JIT)
  test-lib: add LIBPCRE1 &amp; LIBPCRE2 prerequisites
</content>
</entry>
<entry>
<title>grep: fix segfault under -P + PCRE2 &lt;=10.30 + (*NO_JIT)</title>
<updated>2017-11-24T07:12:26Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2017-11-23T14:16:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a25b9085043b8029169b4d5b172b78ca3f38fb37'/>
<id>urn:sha1:a25b9085043b8029169b4d5b172b78ca3f38fb37</id>
<content type='text'>
Fix a bug in the compilation of PCRE2 patterns under JIT (the most
common runtime configuration). Any pattern with a (*NO_JIT) verb would
segfault in any currently released PCRE2 version:

    $ git grep -P '(*NO_JIT)hi.*there'
    Segmentation fault

That this segfaulted was a bug in PCRE2 itself, after reporting it[1]
on pcre-dev it's been fixed in a yet-to-be-released version of
PCRE (presumably released first as 10.31). Now it'll die with:

    $ git grep -P '(*NO_JIT)hi.*there'
    fatal: pcre2_jit_match failed with error code -45: bad JIT option

But the cause of the bug is in our own code dating back to my
94da9193a6 ("grep: add support for PCRE v2", 2017-06-01).

As explained at more length in the comment being added here, it isn't
sufficient to just check pcre2_config() to see whether the JIT should
be used, pcre2_pattern_info() also has to be asked.

This is something I discovered myself when fiddling around with PCRE2
verbs in patterns passed to git. I don't expect that any user of git
has encountered this given the obscurity of passing PCRE2 verbs
through to the library, along with the relative obscurity of (*NO_JIT)
itself.

1. "How am I supposed to use PCRE2 JIT in the face of (*NO_JIT) ?"
   (&lt;CACBZZX5mMqDuWuFmi7sRBp3wH6CFyd-ghACukd=v0NN=rBMnJg@mail.gmail.com&gt; &amp;
    https://lists.exim.org/lurker/thread/20171123.101502.7f0d38ca.en.html)
   on the pcre-dev mailing list

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>grep: show non-empty lines before functions with -W</title>
<updated>2017-11-21T00:36:06Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2017-11-18T18:08:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a5dc20b0701cee53b2c37a4aa3a339b48d5bb298'/>
<id>urn:sha1:a5dc20b0701cee53b2c37a4aa3a339b48d5bb298</id>
<content type='text'>
Non-empty lines before a function definition are most likely comments
for that function and thus relevant.  Include them in function context.

Such a non-empty line might also belong to the preceding function if
there is no separating blank line.  Stop extending the context upwards
also at the next function line to make sure only one extra function body
is shown at most.

Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>grep: update boundary variable for pre-context</title>
<updated>2017-11-21T00:36:06Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2017-11-18T18:07:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6653a01bf2dd1e2aabbcf1f83269bd75737acc94'/>
<id>urn:sha1:6653a01bf2dd1e2aabbcf1f83269bd75737acc94</id>
<content type='text'>
Function context can be bigger than -A/-B/-C context.  To find the
beginning of the combined context we search backwards.  Currently we
check at each loop iteration what we're looking for and determine the
effective upper boundary based on that.

Simplify this a bit by setting the variable "from" to the lowest unshown
line number up front if we're looking for a function line and set it
back to the required -B/-C context line number when we find one.  This
prepares the ground for the next patch; no functional change intended.

Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'ab/pcre-v2'</title>
<updated>2017-11-15T03:14:34Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-11-15T03:14:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2620b47794e3238ee5c7dd6b8a38f58732ace3a2'/>
<id>urn:sha1:2620b47794e3238ee5c7dd6b8a38f58732ace3a2</id>
<content type='text'>
Building with NO_LIBPCRE1_JIT did not disable it, which has been fixed.

* ab/pcre-v2:
  grep: fix NO_LIBPCRE1_JIT to fully disable JIT
</content>
</entry>
</feed>
