Thread (1 message) 1 message, 1 author, 2021-03-31

Re: [PATCH v2 21/22] pickaxe -G: terminate early on matching lines

From: Junio C Hamano <hidden>
Date: 2021-03-31 00:12:46

Ævar Arnfjörð Bjarmason  [off-list ref] writes:
Solve a long-standing item for "git log -Grx" of us e.g. finding "+
str" in the diff context and noting that we had a "hit", but xdiff
diligently continuing to generate and spew the rest of the diff at us.
Nice.  "git log -Gpattern" without "-p" has no reason to do the full
diff once it finds out that pattern would have existed if "-p" were
given in the output.

It actually is a bit of shame that "git log -Gpattern -p" still
needs to run two diffs (instead of taking advantage of the diff that
it needs to generate anyway (to show to the user of the "log") and
pattern match in it).
 	if (data->hit)
+		BUG("Already matched in diffgrep_consume! Broken xdiff_emit_line_fn?");
Hmph, an obvious alternative would be to silently return -1 here,
which probably would not hurt, either.  I do not mind the check to
be stricter, though.
quoted hunk
+	if (!regexec_buf(data->regexp, line + 1, len - 1, 1,
+			 &regmatch, 0)) {
+		data->hit = 1;
+		return -1;
+	}
 	return 0;
 }
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help