http-backend: write newlines to stderr when responding with errors

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

KJ Tsanaktsidis committed Jan 12, 2026 at 01:44 UTC a8227ae8d5410e54c5788283e35b42b7bf5b22ff
1 file changed +6 -2
http-backend.c
+6 -2
@@ -143,8 +143,10 @@ static NORETURN void not_found(struct strbuf *hdr, const char *err, ...)
143 end_headers(hdr);
144
145 va_start(params, err);
146 - if (err && *err)
146 + if (err && *err) {
147 vfprintf(stderr, err, params);
148 + putc('\n', stderr);
149 + }
150 va_end(params);
151 exit(0);
152 }
@@ -159,8 +161,10 @@ static NORETURN void forbidden(struct strbuf *hdr, const char *err, ...)
161 end_headers(hdr);
162
163 va_start(params, err);
162 - if (err && *err)
164 + if (err && *err) {
165 vfprintf(stderr, err, params);
166 + putc('\n', stderr);
167 + }
168 va_end(params);
169 exit(0);
170 }