Re: [PATCH] line-range: skip trailing empty lines in funcname range
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 21, 2026, 17:30 UTC
- Message-ID
- <xmqqse32mrzm.fsf@gitster.g>
- In-Reply-To
- <pull.2234.git.1789991377413.gitgitgadget@gmail.com>
"Kristofer Karlsson via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 13 quoted lines
> diff --git a/line-range.c b/line-range.c > index b99f0d9895..44b52d4e34 100644 > --- a/line-range.c > +++ b/line-range.c > @@ -233,6 +233,11 @@ static const char *parse_range_funcname( > (*end)++; > } > > + /* exclude trailing empty lines from the function range */ > + while (*end > *begin + 1 && > + nth_line_cb(cb_data, *end - 1)[0] == '\n') > + (*end)--; > +
While the new behaviour may mean well, the implementation falls a bit short of matching what "grep -W" did, doesn't it? Over there we treat a line with only whitespace characters on it as an empty line that we want to ignore, but the above code does not allow anything before the LF. I do not know offhand if the above misbehaves on CRLF text files, but if you treated a line with only whitespace characters on it as an empty line, concerns on CRLF files would also disappear ;-).