From: Stefan Sperling Subject: Re: rebase is missing a fflush(stdout) To: Omar Polo Cc: Christian Weisgerber , gameoftrees@openbsd.org Date: Wed, 12 Apr 2023 22:24:09 +0200 On Sat, Apr 01, 2023 at 04:20:25PM +0200, Omar Polo wrote: > On 2023/04/01 15:26:53 +0200, Christian Weisgerber wrote: > > When I try to rebase jca@'s jca/llvm15-12 branch on the latest > > OpenBSD master, I correctly get a merge conflict. I logged the > > output of the whole rebase operation: > > > > $ got rb llvm15 2>&1 | tee ../log > > > > That produces some 11,200 lines. Some 200 lines from the end, > > splatted into another line of output, there's a "got: conflicts > > must be resolved before rebasing can continue". It's also thousands > > of lines from the actual C conflict line. > > > > Looking at cmd_rebase(), I see that "conflicts must be resolved > > before rebasing can continue" should appear at the very end. It's > > issued to stderr, so written right away, while the other output > > goes to stdout and is stuck in a buffer that is only written out > > once got exits. In short, cmd_rebase() or one of the functions it > > calls is missing a fflush(stdout)... but I don't know where the > > most logical place for that would be. > > it could be an idea to flush stdout before printing the error message > in main() to cover all the (sub)commands This cannot hurt, can it? Tests are passing. I'm ok with this. > diff /home/op/w/got > commit - e9e0377f452e9d3f600011e0714cc6c779f10bab > path + /home/op/w/got > blob - a51a450a06ab2800d2fe4a200fc31cc59364dac6 > file + got/got.c > --- got/got.c > +++ got/got.c > @@ -265,6 +265,7 @@ main(int argc, char *argv[]) > error->code == GOT_ERR_ERRNO && errno == EPIPE) && > !(sigint_received && > error->code == GOT_ERR_ERRNO && errno == EINTR)) { > + fflush(stdout); > fprintf(stderr, "%s: %s\n", getprogname(), error->msg); > return 1; > } > >