git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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 ;-).

Previous: Kristofer Karlsson via GitGitGadgetNext: Kristofer Karlsson
Message 2 of 4 in “line-range: skip trailing empty lines in funcname range”
  1. line-range: skip trailing empty lines in funcname rangeKristofer Karlsson via GitGitGadget, Sep 21, 2026
  2. Junio C HamanoSep 21, 2026
  3. Kristofer KarlssonSep 21, 2026
  4. line-range: skip trailing blank lines in funcname rangeKristofer Karlsson via GitGitGadget, Sep 25, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.