On Thu, Jan 16, 2025 at 05:36:20AM -0500, Jeff King wrote: > > -static void vreportf(const char *prefix, const char *err, va_list params) > > +static void vfdreportf(int fd, const char *prefix, const char *err, va_list params) > > { > > char msg[4096]; > > char *p, *pend = msg + sizeof(msg); > > @@ -32,8 +32,14 @@ static void vreportf(const char *prefix, const char *err, va_list params) > > } > > > > *(p++) = '\n'; /* we no longer need a NUL */ > > - fflush(stderr); > > - write_in_full(2, msg, p - msg); > > + if (fd == 2) > > + fflush(stderr); > > + write_in_full(fd, msg, p - msg); > > +} Oh, I meant to mention also: I wondered about the other references to stderr in this function. But we hit those only when we fail to format the error message that was asked for, so continuing to send them to stderr is the right thing (i.e., your patch is right but I wanted to help out other reviewers). -Peff