From: Duy Nguyen Date: Thu, 24 Jul 2014 09:58:31 GMT Subject: Re: [PATCH 3/5] checkout --to: no auto-detach if the ref is already checked out Message-ID: In-Reply-To: <53CFBD2A.9030803@drmicha.warpmail.net> On Wed, Jul 23, 2014 at 8:48 PM, Michael J Gruber wrote: > Nguyễn Thái Ngọc Duy venit, vidit, dixit 23.07.2014 13:43: >> + if (advice_checkout_to) >> + die(_("%s is already checked out at %s.\n" >> + "Either use --detach or -b together with --to " >> + "or switch branch in the the other checkout."), > > "or switch to a different branch in the other checkout". But maybe we > can be even more helpful, like: > > "%s is already checked out at %s.\n" > "Either checkout the detached head of branch %s using\n" > " git checkout --detach --to %s %s\n" > "or checkout a new branch based off %s using\n" > " git checkout --to %s -b %s newbranch %s\n" > "or switch to a different branch in the other checkout." > > if we can figure out the appropriate arguments at this point in the code. We would not be able to construct the exact command that the user has entered, so perhaps git checkout --detach %s git checkout -b %s ? Note that this does not only occur when --to is given. If you have two checkouts associated to the same repo, "git checkout foo" on one checkout when "foo" is held by another checkout would cause the same error. I'll need to think of a better name than advice.checkoutTo. -- Duy