Re: [PATCH 1/1] git-grep: improve the --show-function behaviour
- From
René Scharfe <l.s.r@web.de>
- Date
- Sep 14, 2023, 19:34 UTC
- Message-ID
- <29ea79e7-87fd-fa27-e9df-d626e27c7c74@web.de>
- In-Reply-To
- <xmqq1qf2lxrm.fsf@gitster.g>
Am 13.09.23 um 02:31 schrieb Junio C Hamano:
Show 28 quoted lines
> René Scharfe <l.s.r@web.de> writes:
>
>>>> 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é