git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: Heba Waly via GitGitGadget <gitgitgadget@gmail.com>,
	Git List <git@vger.kernel.org>, Heba Waly <heba.waly@gmail.com>
Subject: Re: [PATCH v2 1/1] branch: advise the user to checkout a different branch before deleting
Date: Tue, 07 Jan 2020 08:34:04 -0800	[thread overview]
Message-ID: <xmqqh8176xab.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <CAPig+cQ0qY8KDZrQ8khuz34DqPimorN7JHHn0Ms=KpvJYtxJoA@mail.gmail.com> (Eric Sunshine's message of "Tue, 7 Jan 2020 06:16:17 -0500")

Eric Sunshine <sunshine@sunshineco.com> writes:

[jc: skipped all the good suggestions I agree with]

>> +                                       }
>> +                                       else {
>> +                                               advise(_("The branch you are trying to delete is checked "
>> +                                                       "out on another worktree, run the following command "
>> +                                                       "to checkout a different branch then try again:\n"
>> +                                                       "git -C %s switch <branch>"), wt->path);
>
> I like the use of -C here because it makes the command self-contained,
> however, I also worry because wt->path is an absolute path, thus
> likely to be quite lengthy, which means that the important part of the
> example command (the "switch <branch>") can get pushed quite far away,
> thus is more easily overlooked by the reader. I wonder if it would
> make more sense to show the 'cd' command explicitly, although doing so
> ties the example to a particular shell, which may be a downside.
>
>     cd %s
>     git switch <different-branch>
>     cd -
>     git branch -%c <this-branch>

Note that wt->path may have special characters that would need to be
protected from the user's shell (worse, the quoting convention may
be different depending on which shell is in use).  That is one of
the reasons why I would suggest to stay away from giving an advice
that pretends to be cut-and-paste-able without being so.  In this
case, <different-branch> and <this-branch> must be filled by the
user anyway, and the only thing worth cutting-and-pasting is the
path to the other worktree, not the "git -C" or "cd" that users
should be able to come up with.

	"The branch is checked out on another worktree at\n"
	"path '%s'\n"
	"and cannot be deleted.  Go there, check out some other\n"
	"branch and try again."

or something like that, perhaps?  

> (It is rather verbose and ugly, though.)

I tend to agree.  It also feels to me that it is giving too much
hand-holding, but after all advise() may turning out to be about
giving that.


  reply	other threads:[~2020-01-07 16:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-02  2:49 [PATCH 0/1] [Outreachy] [RFC] branch: advise the user to checkout a different branch before deleting Heba Waly via GitGitGadget
2020-01-02  2:49 ` [PATCH 1/1] " Heba Waly via GitGitGadget
2020-01-02  8:18   ` Eric Sunshine
2020-01-06  0:42     ` Heba Waly
2020-01-07  4:10 ` [PATCH v2 0/1] [Outreachy] [RFC] " Heba Waly via GitGitGadget
2020-01-07  4:10   ` [PATCH v2 1/1] " Heba Waly via GitGitGadget
2020-01-07 11:16     ` Eric Sunshine
2020-01-07 16:34       ` Junio C Hamano [this message]
2020-01-08  1:44         ` Emily Shaffer
2020-01-08 10:22           ` Eric Sunshine
2020-01-08  1:14       ` Heba Waly
2020-01-08  9:27         ` Eric Sunshine
2020-01-08 18:06           ` Heba Waly
2020-01-08 19:01             ` Johannes Schindelin
2020-01-08 19:15               ` Junio C Hamano
2020-01-10 12:11                 ` Heba Waly
2020-01-08 19:05             ` Junio C Hamano
2020-01-10 12:09           ` Heba Waly

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=xmqqh8176xab.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=heba.waly@gmail.com \
    --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).