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

Re: Improved Rust hunk headers

From
D. Ben Knoble <ben.knoble@gmail.com>
Date
Jan 8, 2026, 17:29 UTC
Message-ID
<CALnO6CAGHuu9zBNRD1PV+2ej9pSq=2agP76hA3ZWXxojo7FJug@mail.gmail.com>
In-Reply-To
<DFJ7PJVEVOYG.377TM7121KCQJ@kernel.org>
On Thu, Jan 8, 2026 at 10:34 AM Benno Lossin <lossin@kernel.org> wrote:
Show 21 quoted lines
>
> Hey everyone,
>
> Recently, while looking at a Rust patch [1] for the Linux kernel, I had
> an idea to improve the hunk header for Rust code. The patch's hunk
> header is the function defined above the addition. To me it doesn't
> provide much value in giving context; it has been a while since I last
> looked at that file. It would be much more useful in this case to show
> the context `pub unsafe trait FromBytes {` instead. This is because the
> function that's being added is added to that trait.
>
> In the general case it still is useful to show the function context when
> the contents of a function are changed. Ideally, it would be possible to
> show both the `impl` block and the function signature.
>
> I have no knowledge of the inner workings of git, so this might be a
> tall ask. But would it be possible to implement having multi-line hunk
> headers and have a more advanced selection algorithm? AFAIK at the
> moment a regex is used to extract the header, I think that would still
> be sufficient for this case, if the `impl` block header is searched for
> after the function signature.

I wonder if an empty hunk (that is, two adjacent headers) would break anything? Just thinking aloud.

-- 
D. Ben Knoble
Previous: Benno Lossin
Message 2 of 2 in “Improved Rust hunk headers”
  1. Benno LossinJan 8, 2026
  2. D. Ben KnobleJan 8, 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.