summaryrefslogtreecommitdiff
path: root/list-objects.c
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2018-06-22 15:49:35 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-06-22 19:59:02 (GMT)
commit68d686e6af0fc192fce1788f67bbe0c21a5419ab (patch)
tree65fb8399de80ad79e25e51bfb808606ea9551991 /list-objects.c
parentf8a0c6e799b98f6b502eadfadcf6acc103d6f7c6 (diff)
downloadgit-68d686e6af0fc192fce1788f67bbe0c21a5419ab.zip
git-68d686e6af0fc192fce1788f67bbe0c21a5419ab.tar.gz
git-68d686e6af0fc192fce1788f67bbe0c21a5419ab.tar.bz2
grep.c: expose {,inverted} match column in match_line()
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 <peff@peff.net> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'list-objects.c')
0 files changed, 0 insertions, 0 deletions