From: Junio C Hamano <gitster@pobox.com>
To: Alex Henrie <alexhenrie24@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] switch: mention the --detach option when dying due to lack of a branch
Date: Wed, 23 Feb 2022 15:07:06 -0800 [thread overview]
Message-ID: <xmqqwnhlp4h1.fsf@gitster.g> (raw)
In-Reply-To: <20220223073125.640133-1-alexhenrie24@gmail.com> (Alex Henrie's message of "Wed, 23 Feb 2022 00:31:25 -0700")
Alex Henrie <alexhenrie24@gmail.com> writes:
> Users who are accustomed to doing `git checkout <tag>` assume that
> `git switch <tag>` will do the same thing. Inform them of the --detach
> option so they aren't left wondering why `git switch` doesn't work but
> `git checkout` does.
An error message certainly would help over showing
fatal: a branch is expected, got tag 'abc'
but I have to wonder why we shouldn't DWIM and detach the HEAD at
the commit the user wanted to. That would also solve the issue of
leaving them wondering why switch is broken and checkout is not, no?
If the advice for detached HEAD state is enabled, then the user will
be reminded that they are not on any branch the usual way when the
HEAD is detached at the named commit. And if the advice is not
enabled, then they will not be helped by this new advise() message
we add here.
> + if (advice_enabled(ADVICE_DETACHED_HEAD))
> + advise(_("The specified commit is not a local branch.\n"
> + "If you want to enter detached head mode, try again with the --detach option."));
> +
"detached HEAD" is a state, and not a mode.
s/enter detached head mode/detach HEAD at the commit/ perhaps.
Thanks.
next prev parent reply other threads:[~2022-02-23 23:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-23 7:31 [PATCH] switch: mention the --detach option when dying due to lack of a branch Alex Henrie
2022-02-23 23:07 ` Junio C Hamano [this message]
2022-02-23 23:30 ` Alex Henrie
2022-02-23 23:56 ` Ævar Arnfjörð Bjarmason
2022-02-24 6:08 ` Alex Henrie
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqwnhlp4h1.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=alexhenrie24@gmail.com \
--cc=git@vger.kernel.org \
/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.
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 NNTP newsgroup(s).