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

[PATCH v2] http-backend: write newlines to stderr when responding with errors

From
KJ Tsanaktsidis <kj@kjtsanaktsidis.id.au>
Date
Jan 12, 2026, 01:44 UTC
Message-ID
<20260112014508.17248-1-kj@kjtsanaktsidis.id.au>
In-Reply-To
<xmqqpl7govl8.fsf@gitster.g>

The not_found and forbidden methods currently do not write a newline to stderr after the error message. This means that if git-http-backend is invoked through something like fcgiwrap, and the stderr of that fcgiwrap process is sent to a logging daemon (e.g. journald), the error messages of several git-http-backend invocations will just get strung together, e.g.

> Not a git repository: '/var/lib/git/foo.git'Not a git repository: '/var/lib/git/foo.git'Not a git repository: '/var/lib/git/foo.git'

I think it's git-http-backend's responsibility to format these messages properly, rather than it being fcgiwrap's job to notice that the script didn't terminate stderr with a newline and do so itself.

Signed-off-by: KJ Tsanaktsidis <kj@kjtsanaktsidis.id.au>
---
 http-backend.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/http-backend.c b/http-backend.c
index 52f0483dd3..8c810cfcbd 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -143,8 +143,10 @@ static NORETURN void not_found(struct strbuf *hdr, const char *err, ...)
 	end_headers(hdr);
 
 	va_start(params, err);
-	if (err && *err)
+	if (err && *err) {
 		vfprintf(stderr, err, params);
+		putc('\n', stderr);
+	}
 	va_end(params);
 	exit(0);
 }
@@ -159,8 +161,10 @@ static NORETURN void forbidden(struct strbuf *hdr, const char *err, ...)
 	end_headers(hdr);
 
 	va_start(params, err);
-	if (err && *err)
+	if (err && *err) {
 		vfprintf(stderr, err, params);
+		putc('\n', stderr);
+	}
 	va_end(params);
 	exit(0);
 }
-- 
2.51.2
Previous: Junio C HamanoNext: KJ Tsanaktsidis
Message 3 of 4 in “http-backend: write newlines to stderr when responding with errors”
  1. http-backend: write newlines to stderr when responding with errorsKJ Tsanaktsidis, Jan 8, 2026
  2. Junio C HamanoJan 11, 2026
  3. http-backend: write newlines to stderr when responding with errorsKJ Tsanaktsidis, Jan 12, 2026
  4. KJ TsanaktsidisJan 12, 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.