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

Re: trailers: --only-trailers normalizes URLs to trailers

From
Jeff King <peff@peff.net>
Date
Jun 9, 2026, 00:43 UTC
Message-ID
<20260609004340.GF358144@coredump.intra.peff.net>
In-Reply-To
<ae4a32e7-bacb-4c88-b2a0-5aeaff60b904@app.fastmail.com>
On Thu, Jun 04, 2026 at 11:27:51PM +0200, Kristoffer Haugsbakk wrote:
> The following is a bug that follows straightforwardly from the documented
> or discussed behavior. In that sense it is not a bug. But it is a bug in
> the sense that it makes things inconvenient and violates a design goal.

Yeah, though if you'll allow me to nitpick your subject a moment: I don't think --only-trailers is really the culprit here. It demonstrates the problem because it normalizes the "trailer" it found. But the loose trailer matching is the more fundamental issue. For example:

git interpret-trailers --trailer=foo=bar <<\EOF subject

body

http://example.com EOF

will stick the new "foo: bar" trailer right up against the (now-broken) "http:" trailer. When it should come in its own stanza, which it would if you added a line "other" at the end, since that tells us that "http:" can't be a trailer.

Show 9 quoted lines
> > What's different between what you expected and what actually happened?
> 
> In an ideal world to have some special-casing of URLs so that they are
> not detected as trailers. Does anyone realistically want trailers like
> this?:
> 
>     file: //...
>     http: //...
>     https: //...

I could even see those as trailers, if somebody really wanted to allow arbitrary values that might just happen to start with "//". But without the whitespace after the colon, it is quite questionable.

> Just special-casing `https` would go a long way.

Agreed, though I think a rule like: ":// (with no whitespace)" is not a valid separator. Something like this:

diff --git a/trailer.c b/trailer.c
index 6d8ec7fa8d..342ed81c78 100644
--- a/trailer.c
+++ b/trailer.c
@@ -635,8 +635,12 @@ 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)) {
+			/* special case to avoid accidental URL matches */
+			if (*c == ':' && c[1] == '/' && c[2] == '/')
+				return -1;
 			return c - line;
+		}
 		if (!whitespace_found && (isalnum(*c) || *c == '-'))
 			continue;
 		if (c != line && (*c == ' ' || *c == '\t')) {

-Peff
Previous: Kristoffer HaugsbakkNext: Kristoffer Haugsbakk
Message 2 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.