git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: <rsbecker@nexbridge.com>
To: "'Eric Sunshine'" <sunshine@sunshineco.com>,
	"'Baruch Burstein'" <bmburstein@gmail.com>
Cc: "'Git List'" <git@vger.kernel.org>
Subject: RE: misleading message printed when worktree add fails
Date: Sun, 28 Nov 2021 12:11:18 -0500	[thread overview]
Message-ID: <010001d7e47a$f8b4cae0$ea1e60a0$@nexbridge.com> (raw)
In-Reply-To: <CAPig+cTGq-10ZTBts2LXRVdPMf2vNMX8HTuhg_+ZHSiLX-brOQ@mail.gmail.com>

On November 28, 2021 12:01 PM, Eric Sunshine wrote:
> On Sun, Nov 28, 2021 at 11:47 AM Baruch Burstein <bmburstein@gmail.com>
> 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.

This is probably a good idea. There is no guarantee even in Unix regarding stream buffer flushing. If there is a reason to sequence output between stdout and stderr, then fflush is important.

-Randall


  reply	other threads:[~2021-11-28 17:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-28  6:50 misleading message printed when worktree add fails Baruch Burstein
2021-11-28 12:37 ` Eric Sunshine
2021-11-28 16:47   ` Baruch Burstein
2021-11-28 17:00     ` Eric Sunshine
2021-11-28 17:11       ` rsbecker [this message]
2021-11-30  4:46       ` Eric Sunshine

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='010001d7e47a$f8b4cae0$ea1e60a0$@nexbridge.com' \
    --to=rsbecker@nexbridge.com \
    --cc=bmburstein@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=sunshine@sunshineco.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).