Thread (5 messages) 5 messages, 3 authors, 2023-09-17

Re: [PATCH 1/1] git-grep: improve the --show-function behaviour

From: René Scharfe <hidden>
Date: 2023-09-14 19:34:57

Possibly related (same subject, not in this thread)


Am 13.09.23 um 02:31 schrieb Junio C Hamano:
René Scharfe [off-list ref] writes:
quoted
quoted
quoted
To me, this behaviour looks as

		Show the preceding line that contains the function name of
		the match, unless the _PREVIOUS_ matching line is a function
		name itself.
To me it looks like:

		Show the preceding line that contains the function name of
		the match.

("Show" meaning "show once", not "show for each match again and again".)

Or:

		Show the preceding line that contains the function name of
		the match, unless it is already shown for a different
		reason, e.g. as a match or as the function line of a
		previous match.
Wow, that was a mouthful, but matches my understanding.  I naïvely
thought "when showing a hit, we may add the line that matches the
function header pattern before the hit even that header line does
not hit the grep pattern. But if the header line does hit the grep
pattern, we do not bother show the same thing twice." was a
reasonable goal to have.
I agree, and that's probably why I included the "unless the matching
line is a function name itself" part.  Not sure why the code doesn't
agree.  A test for that aspect would have been nice. *ahem*

René
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help