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

Re: [PATCH] trailers: stop recognizing URLs as trailers

From
Jeff King <peff@peff.net>
Date
Aug 3, 2026, 15:20 UTC
Message-ID
<20260803152025.GA189075@coredump.intra.peff.net>
In-Reply-To
<URLs_not_trailers.b13@msgid.xyz>
On Sun, Aug 02, 2026 at 09:57:17PM +0200, kristofferhaugsbakk@fastmail.com wrote:
Show 12 quoted lines
> There are commits which contain intended non-trailer lines which start
> with URLs. These are comments. Example with just the trailers:[2]
> 
>     Signed-off-by: Shuai Xue <xueshuai@linux.alibaba.com>
>     [bhelgaas: squash fixes:
>     https://lore.kernel.org/r/20260108013956.14351-2-bagasdotme@gmail.com
>     https://lore.kernel.org/r/20260108013956.14351-3-bagasdotme@gmail.com]
>     Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>     Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
>     Link: https://patch.msgid.link/20251210132907.58799-4-xueshuai@linux.alibaba.com
> 
> Those `[]` pairs delimit the “squash fixes” comment.

This example makes me wonder if we ought to be smarter about brackets. I.e., could/should we realize that the opening bracket is a comment and then ignore everything up to the closing one? That would help this case and other weird cases like:

  Signed-off-by: whomever
  [peff: there's a really interesting thing going on
  here: the comment is free-form text that happens to
  use a colon in a sentence, but we'll interpret it
  as a trailer with key "here"]
  Signed-off-by: another unlucky soul

That said, I think there are cases without brackets that are also confusing. Like:

  Let me finish this commit message by telling you all about this
  amazing url:
  https://example.com

So I don't think that is a counter-argument against this URL false-positive check, but just a possible direction for future exploration.

Show 14 quoted lines
> Another example is linewrapping mistakes; a `Link` trailer with a
> URL where the URL ended up on the next line, presumably because the
> user’s editor linewrapped the “too long” line. Example with just the
> trailers:[3]
> 
>     Link: https://patch.msgid.link/20260216-work-xattr-socket-v1-4-c2efa4f74cb7@kernel.org
>     Link:
>     https://lore.kernel.org/3cnmtqmakpbb2uwhenrj7kdqu3uefykiykjllgfbtpkiwhaa4s@sghkevv7jned [1]
>     Acked-by: Darrick J. Wong <djwong@kernel.org>
>     Reviewed-by: Jan Kara <jack@suse.cz>
>     Signed-off-by: Christian Brauner <brauner@kernel.org>
> 
> Now, this intended trailer is already ruined, but interpreting the URL
> as a standalone trailer only compounds the mistake.

Yeah, this is another interesting example. I agree it is fundamentally broken, but showing the "https" trailer is just making it worse.

Show 16 quoted lines
> diff --git a/trailer.c b/trailer.c
> index 6d8ec7fa8d8..971ae459596 100644
> --- a/trailer.c
> +++ b/trailer.c
> @@ -635,8 +635,13 @@ static ssize_t find_separator(const char *line, const char *separators)
>  	int whitespace_found = 0;
>  	const char *c;
>  	for (c = line; *c; c++) {
> -		if (strchr(separators, *c))
> +		if (strchr(separators, *c)) {
> +			/* avoid accidental URL matches (://) */
> +			if (*c == ':' && c[1] == '/' && c[2] == '/' &&
> +			    !whitespace_found)
> +				return -1;
>  			return c - line;
> +		}

As discussed elsewhere, we are free to match with short-circuiting because of the NUL termination. But that also means we could write this as:

  if (starts_with(c, "://") && !whitespace_found)
which is perhaps a little more readable.
-Peff
Previous: Kristoffer HaugsbakkNext: Junio C Hamano
Message 9 of 18 in “trailers: --only-trailers normalizes URLs to trailers”
  1. Kristoffer HaugsbakkJun 4, 2026
  2. Jeff KingJun 9, 2026
  3. Kristoffer HaugsbakkJun 10, 2026
  4. Jeff KingJun 11, 2026
  5. Kristoffer HaugsbakkJun 11, 2026
  6. trailers: stop recognizing URLs as trailerskristofferhaugsbakk@fastmail.com, Aug 2, 2026
  7. Junio C HamanoAug 2, 2026
  8. Kristoffer HaugsbakkAug 3, 2026
  9. Jeff KingAug 3, 2026
  10. Junio C HamanoAug 3, 2026
  11. Kristoffer HaugsbakkAug 6, 2026
  12. Junio C HamanoAug 20, 2026
  13. Kristoffer HaugsbakkAug 20, 2026
  14. Jeff KingAug 21, 2026
  15. trailers: stop recognizing URLs as trailerskristofferhaugsbakk@fastmail.com, Aug 20, 2026
  16. trailers: stop recognizing URLs as trailerskristofferhaugsbakk@fastmail.com, Aug 21, 2026
  17. Kristoffer HaugsbakkAug 21, 2026
  18. Junio C HamanoAug 21, 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.