From: Junio C Hamano <gitster@pobox.com>
To: KJ Tsanaktsidis <kj@kjtsanaktsidis.id.au>
Cc: git@vger.kernel.org, KJ Tsanaktsidis <kjtsanaktsidis@groq.com>
Subject: Re: [PATCH] http-backend: write newlines to stderr when responding with errors
Date: Sun, 11 Jan 2026 10:25:23 -0800 [thread overview]
Message-ID: <xmqqpl7govl8.fsf@gitster.g> (raw)
In-Reply-To: <20260108225926.3587282-1-kj@kjtsanaktsidis.id.au> (KJ Tsanaktsidis's message of "Thu, 8 Jan 2026 22:59:21 +0000")
KJ Tsanaktsidis <kj@kjtsanaktsidis.id.au> writes:
> From: KJ Tsanaktsidis <kjtsanaktsidis@groq.com>
>
> 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.
Now another question is which between the callers and these two
helper functions is responsible to ensure that the message
terminates with LF. As these functions can be called only once, I
think letting them add LF makes sense (if they can be called twice
or more, we can imagine that a caller may find it useful to make two
calls to produce a single log entry by ending only the later call
with LF, but such a use-case clearly cannot be supported with these
NORETURN functions). So I think this design makes sense.
> 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..bda8bb91e1 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);
> + fprintf(stderr, "\n");
Somehow it feels overly heavyweight to call fprintf() just to send a
single literal byte to the standard error stream. putc('\n', stderr)
perhaps? The same comment forr the other hunk.
> + }
> 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);
> + fprintf(stderr, "\n");
> + }
> va_end(params);
> exit(0);
> }
next prev parent reply other threads:[~2026-01-11 18:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-08 22:59 [PATCH] http-backend: write newlines to stderr when responding with errors KJ Tsanaktsidis
2026-01-11 18:25 ` Junio C Hamano [this message]
2026-01-12 1:44 ` [PATCH v2] " KJ Tsanaktsidis
2026-01-12 1:47 ` [PATCH] " KJ Tsanaktsidis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqpl7govl8.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=kj@kjtsanaktsidis.id.au \
--cc=kjtsanaktsidis@groq.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox