]> git.ipfire.org Git - thirdparty/git.git/commitdiff
http-backend: write newlines to stderr when responding with errors
authorKJ Tsanaktsidis <kj@kjtsanaktsidis.id.au>
Mon, 12 Jan 2026 01:44:39 +0000 (01:44 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 12 Jan 2026 04:54:01 +0000 (20:54 -0800)
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>
http-backend.c

index 52f0483dd309d73a1866a1b63161df0fe63d389f..8c810cfcbddc738014a3ab17d0efb9721cc3f636 100644 (file)
@@ -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);
 }