<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/grep.c, branch v2.19.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.19.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.19.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2018-08-02T22:30:44Z</updated>
<entry>
<title>Merge branch 'tb/grep-only-matching'</title>
<updated>2018-08-02T22:30:44Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2018-08-02T22:30:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=87ece7ce1133ebc5d339cad5f6f92c02e5fc712d'/>
<id>urn:sha1:87ece7ce1133ebc5d339cad5f6f92c02e5fc712d</id>
<content type='text'>
"git grep" learned the "--only-matching" option.

* tb/grep-only-matching:
  grep.c: teach 'git grep --only-matching'
  grep.c: extract show_line_header()
</content>
</entry>
<entry>
<title>Merge branch 'tb/grep-column'</title>
<updated>2018-07-18T19:20:31Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2018-07-18T19:20:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d036d667b7f297f8305ffaaec212a95da7022ebe'/>
<id>urn:sha1:d036d667b7f297f8305ffaaec212a95da7022ebe</id>
<content type='text'>
"git grep" learned the "--column" option that gives not just the
line number but the column number of the hit.

* tb/grep-column:
  contrib/git-jump/git-jump: jump to exact location
  grep.c: add configuration variables to show matched option
  builtin/grep.c: add '--column' option to 'git-grep(1)'
  grep.c: display column number of first match
  grep.[ch]: extend grep_opt to allow showing matched column
  grep.c: expose {,inverted} match column in match_line()
  Documentation/config.txt: camel-case lineNumber for consistency
</content>
</entry>
<entry>
<title>Merge branch 'sb/object-store-grafts'</title>
<updated>2018-07-18T19:20:28Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2018-07-18T19:20:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=00624d608cc69bd62801c93e74d1ea7a7ddd6598'/>
<id>urn:sha1:00624d608cc69bd62801c93e74d1ea7a7ddd6598</id>
<content type='text'>
The conversion to pass "the_repository" and then "a_repository"
throughout the object access API continues.

* sb/object-store-grafts:
  commit: allow lookup_commit_graft to handle arbitrary repositories
  commit: allow prepare_commit_graft to handle arbitrary repositories
  shallow: migrate shallow information into the object parser
  path.c: migrate global git_path_* to take a repository argument
  cache: convert get_graft_file to handle arbitrary repositories
  commit: convert read_graft_file to handle arbitrary repositories
  commit: convert register_commit_graft to handle arbitrary repositories
  commit: convert commit_graft_pos() to handle arbitrary repositories
  shallow: add repository argument to is_repository_shallow
  shallow: add repository argument to check_shallow_file_for_update
  shallow: add repository argument to register_shallow
  shallow: add repository argument to set_alternate_shallow_file
  commit: add repository argument to lookup_commit_graft
  commit: add repository argument to prepare_commit_graft
  commit: add repository argument to read_graft_file
  commit: add repository argument to register_commit_graft
  commit: add repository argument to commit_graft_pos
  object: move grafts to object parser
  object-store: move object access functions to object-store.h
</content>
</entry>
<entry>
<title>grep.c: teach 'git grep --only-matching'</title>
<updated>2018-07-09T21:15:28Z</updated>
<author>
<name>Taylor Blau</name>
<email>me@ttaylorr.com</email>
</author>
<published>2018-07-09T20:33:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9d8db06eb4a5d5577db559a0059a377914c1ce5a'/>
<id>urn:sha1:9d8db06eb4a5d5577db559a0059a377914c1ce5a</id>
<content type='text'>
Teach 'git grep --only-matching', a new option to only print the
matching part(s) of a line.

For instance, a line containing the following (taken from README.md:27):

  (`man gitcvs-migration` or `git help cvs-migration` if git is

Is printed as follows:

  $ git grep --line-number --column --only-matching -e git -- \
    README.md | grep ":27"
  README.md:27:7:git
  README.md:27:16:git
  README.md:27:38:git

The patch works mostly as one would expect, with the exception of a few
considerations that are worth mentioning here.

Like GNU grep, this patch ignores --only-matching when --invert (-v) is
given. There is a sensible answer here, but parity with the behavior of
other tools is preferred.

Because a line might contain more than one match, there are special
considerations pertaining to when to print line headers, newlines, and
how to increment the match column offset. The line header and newlines
are handled as a special case within the main loop to avoid polluting
the surrounding code with conditionals that have large blocks.

Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>grep.c: extract show_line_header()</title>
<updated>2018-07-03T22:10:30Z</updated>
<author>
<name>Taylor Blau</name>
<email>me@ttaylorr.com</email>
</author>
<published>2018-07-03T21:51:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c707ded332375a5b51c1acf9b7ce1c29cbd4536d'/>
<id>urn:sha1:c707ded332375a5b51c1acf9b7ce1c29cbd4536d</id>
<content type='text'>
The grep code invokes show_line() to display the contents of a matched
or context line in its output. Part of this execution is to print a line
header that includes information such as the kind, the line- and
column-number and etc. of that match.

To prepare for the addition of an option to print only the matching
component(s) of a non-context line, we must prepare for the possibility
that a single line may contain multiple matching parts, and thus will
need multiple headers printed for a single line.

Extracting show_line_header allows us to do just that. In the subsequent
commit, it will be used within the colorization loop to print out only
the matching parts of a line, optionally with LFs delimiting
sub-matches.

Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'nd/complete-config-vars'</title>
<updated>2018-06-25T20:22:38Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2018-06-25T20:22:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ebaf0a56f3f5f823df4166bc8fd626b523f864dc'/>
<id>urn:sha1:ebaf0a56f3f5f823df4166bc8fd626b523f864dc</id>
<content type='text'>
Continuing with the idea to programatically enumerate various
pieces of data required for command line completion, teach the
codebase to report the list of configuration variables
subcommands care about to help complete them.

* nd/complete-config-vars:
  completion: complete general config vars in two steps
  log-tree: allow to customize 'grafted' color
  completion: support case-insensitive config vars
  completion: keep other config var completion in camelCase
  completion: drop the hard coded list of config vars
  am: move advice.amWorkDir parsing back to advice.c
  advice: keep config name in camelCase in advice_config[]
  fsck: produce camelCase config key names
  help: add --config to list all available config
  fsck: factor out msg_id_info[] lazy initialization code
  grep: keep all colors in an array
  Add and use generic name-&gt;id mapping code for color slot parsing
</content>
</entry>
<entry>
<title>grep.c: add configuration variables to show matched option</title>
<updated>2018-06-22T19:59:02Z</updated>
<author>
<name>Taylor Blau</name>
<email>me@ttaylorr.com</email>
</author>
<published>2018-06-22T15:49:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6653fec3bb969d8be3987cf77654c0aa1778b6b5'/>
<id>urn:sha1:6653fec3bb969d8be3987cf77654c0aa1778b6b5</id>
<content type='text'>
To support git-grep(1)'s new option, '--column', document and teach
grep.c how to interpret relevant configuration options, similar to those
associated with '--line-number'.

Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>grep.c: display column number of first match</title>
<updated>2018-06-22T19:59:02Z</updated>
<author>
<name>Taylor Blau</name>
<email>me@ttaylorr.com</email>
</author>
<published>2018-06-22T15:49:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=89252cd069d4acf1c6c407f00c7a1cc2c6ad3953'/>
<id>urn:sha1:89252cd069d4acf1c6c407f00c7a1cc2c6ad3953</id>
<content type='text'>
To prepare for 'git grep' learning '--column', teach grep.c's
show_line() how to show the column of the first match on non-context
lines.

Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>grep.[ch]: extend grep_opt to allow showing matched column</title>
<updated>2018-06-22T19:59:02Z</updated>
<author>
<name>Taylor Blau</name>
<email>me@ttaylorr.com</email>
</author>
<published>2018-06-22T15:49:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=017c0fcfdb21dd44e2c83f533e9a6d78513e7d8c'/>
<id>urn:sha1:017c0fcfdb21dd44e2c83f533e9a6d78513e7d8c</id>
<content type='text'>
To support showing the matched column when calling 'git-grep(1)', teach
'grep_opt' the normal set of options to configure the default behavior
and colorization of this feature.

Now that we have opt-&gt;columnnum, use it to disable short-circuiting over
ORs and ANDs so that col and icol are always filled with the earliest
matches on each line. In addition, don't return the first match from
match_line(), for the same reason.

Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>grep.c: expose {,inverted} match column in match_line()</title>
<updated>2018-06-22T19:59:02Z</updated>
<author>
<name>Taylor Blau</name>
<email>me@ttaylorr.com</email>
</author>
<published>2018-06-22T15:49:35Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=68d686e6af0fc192fce1788f67bbe0c21a5419ab'/>
<id>urn:sha1:68d686e6af0fc192fce1788f67bbe0c21a5419ab</id>
<content type='text'>
When calling match_line(), callers presently cannot determine the
relative offset of the match because match_line() discards the
'regmatch_t' that contains this information.

Instead, teach match_line() to take in two 'ssize_t's. Fill the first
with the offset of the match produced by the given expression. If
extended, fill the later with the offset of the match produced as if
--invert were given.

For instance, matching "--not -e x" on this line produces a columnar
offset of 0, (i.e., the whole line does not contain an x), but "--invert
--not -e -x" will fill the later ssize_t of the column containing an
"x", because this expression is semantically equivalent to "-e x".

To determine the column for the inverted and non-inverted case, do the
following:

  - If matching an atom, the non-inverted column is as given from
    match_one_pattern(), and the inverted column is unset.

  - If matching a --not, the inverted column and non-inverted column
    swap.

  - If matching an --and, or --or, the non-inverted column is the
    minimum of the two children.

Presently, the existing short-circuiting logic for AND and OR applies as
before. This will change in the following commit when we add options to
configure the --column flag. Taken together, this and the forthcoming
change will always yield the earlier column on a given line.

This patch will become useful when we later pick between the two new
results in order to display the column number of the first match on a
line with --column.

Co-authored-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
