From: "Benno Lossin" <lossin@kernel.org>
To: <git@vger.kernel.org>
Subject: Improved Rust hunk headers
Date: Thu, 08 Jan 2026 13:38:35 +0100 [thread overview]
Message-ID: <DFJ7PJVEVOYG.377TM7121KCQJ@kernel.org> (raw)
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.
My current solution to reviewing a patch like this is either opening the
file and scrolling to the change location. This isn't possible if
earlier patches in a series already changed the file. In that case the
only option is to create a new worktree and apply the patch series. It
would be great if I didn't have to do this for simple things.
Cheers,
Benno
[1]: https://lore.kernel.org/all/20251216-transmute-v2-1-b23e5277ad02@google.com/
next reply other threads:[~2026-01-08 12:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-08 12:38 Benno Lossin [this message]
2026-01-08 17:29 ` Improved Rust hunk headers D. Ben Knoble
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DFJ7PJVEVOYG.377TM7121KCQJ@kernel.org \
--to=lossin@kernel.org \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox