Re: misleading message printed when worktree add fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[please comment inline on this list rather than top-posting]

On Sun, Nov 28, 2021 at 11:47 AM Baruch Burstein <bmburstein@xxxxxxxxx> wrote:
> > When I perform these actions, I see a "fatal error" message which
> > clearly indicates failure, not success:
> >
> >     % git worktree add ../foo bar
> >     Preparing worktree (checking out 'bar')
> >     fatal: 'bar' is already checked out at '.../wherever'
>
> I see them in the other order:
>
>     fatal: 'master' is already checked out at 'C:/Users/bmbur/temp'
>     Preparing worktree (checking out 'master')
>
> which I understood as "there was an error, but we managed to recover
> somehow and set up the worktree anyway"

Okay, that's happening because the "Preparing" message is sent to
stdout, whereas the "fatal" error is sent to stderr, and the streams
are being flushed on Windows in a different order than what we
typically see on Unix platforms even though the "Preparing" message is
actually output first by the code.

A general fix (not specific to git-worktree) might be to have die()
(or maybe vreportf()?) flush stdout before reporting the error message
on stderr. That should make output order more predictable, such that
general status messages appear before error messages.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux