git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* git switch error message tweak
@ 2020-06-16  6:47 Ed Avis
  2020-06-17 20:30 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Ed Avis @ 2020-06-16  6:47 UTC (permalink / raw)
  To: git@vger.kernel.org

To help those migrating from 'git checkout' to the newer 'git switch'
and 'git restore', this error message could be improved:

% git switch baa022666d26a5d40e86c0b6349eb7435033e80a
fatal: a branch is expected, got commit 'baa022666d26a5d40e86c0b6349eb7435033e80a'

It could print additionally

To switch to this commit in 'detached HEAD' mode, use --detach.

as long as it was indeed a commit that was given.

I note also that while git checkout prints a spiel about "You are in
'detached HEAD' state", git switch --detach does not.  Was this
deliberate, on the assumption that if you pass --detach you know what
you are doing?  I think it might be better to honour the
advice.detachedHead setting the same way for both checkout and switch.

Thanks for considering this request, and apologies if this is something already discussed and decided.

-- 
Ed Avis <ed.avis@qmaw.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: git switch error message tweak
  2020-06-16  6:47 git switch error message tweak Ed Avis
@ 2020-06-17 20:30 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2020-06-17 20:30 UTC (permalink / raw)
  To: Ed Avis; +Cc: git@vger.kernel.org

Ed Avis <ed.avis@qmaw.com> writes:

> To help those migrating from 'git checkout' to the newer 'git switch'
> and 'git restore', this error message could be improved:
>
> % git switch baa022666d26a5d40e86c0b6349eb7435033e80a
> fatal: a branch is expected, got commit 'baa022666d26a5d40e86c0b6349eb7435033e80a'
>
> It could print additionally
>
> To switch to this commit in 'detached HEAD' mode, use --detach.
>
> as long as it was indeed a commit that was given.

Excellent.

> I note also that while git checkout prints a spiel about "You are in
> 'detached HEAD' state", git switch --detach does not. Was this
> deliberate, on the assumption that if you pass --detach you know what
> you are doing?

I'd say you are correct---one who passes "--detach" knows enough to
want to be in the detached HEAD state and knows enough that the
state is nothing to be worried about.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-17 20:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-16  6:47 git switch error message tweak Ed Avis
2020-06-17 20:30 ` Junio C Hamano

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).