From: Phillip Wood <phillip.wood123@gmail.com>
To: "Junio C Hamano" <gitster@pobox.com>, "René Scharfe" <l.s.r@web.de>
Cc: Toon Claes <toon@iotcl.com>, Patrick Steinhardt <ps@pks.im>,
Git List <git@vger.kernel.org>, stsp <stsp2@yandex.ru>
Subject: Re: [PATCH] branch: report kind of checkout when rejecting delete
Date: Sun, 19 Jul 2026 10:50:59 +0100 [thread overview]
Message-ID: <03a332e0-afaa-4562-a503-2ff8a8f9f2ac@gmail.com> (raw)
In-Reply-To: <xmqqa4roq7a8.fsf@gitster.g>
On 18/07/2026 23:09, Junio C Hamano wrote:
> René Scharfe <l.s.r@web.de> writes:
>
>>>> + switch (kind) {
>>>> + case BRANCH_CHECKOUT_KIND_CHECKOUT:
>>>> + error(_("cannot delete branch '%s' "
>>>> + "used by worktree at '%s'"),
>>>> + bname.buf, path);
>>>> + break;
>>>
>>> We may want to be more explicit and say "cannot delete
>>> branch 'frotz' checked out in worktree at '/tmp/nitfol'"
>>> instead. Unless this is a catch-all entry for states that
>>> are neither 'rebase', 'bisect', nor 'rebase-merges' but are
>>> somehow otherwise in use, that is.
That's a great suggestion, I don't think there are any other cases so it
should be fine to say "checked out".
>>>> + case BRANCH_CHECKOUT_KIND_UPDATE_REF:
>>>> + error(_("cannot delete branch '%s' "
>>>> + "used by worktree at '%s' "
>>>> + "for update-ref"),
>>>> + bname.buf, path);
>>>> + break;
>>>
>>> I was quite lost when searching for cases where this 'update-ref'
>>> state might be encountered, and I still lack confidence. Can
>>> we make the diagnostic message a bit friendlier to our users?
>>>
>>> For instance, something like: 'You are rebasing a history with
>>> merges in that other worktree, and the tip of this branch will
>>> be updated when that process completes, so you cannot delete
>>> it from here.' (Naturally, I may have misidentified the exact
>>> nature of the error, but this illustrates the level of detail and
>>> user-facing clarity I hope to see.)
>>
>> That's quite long. Would it make sense to throw that update-ref
>> case into the rebase bin, i.e. only distinguish between checkout,
>> bisect and rebase?
I also wondered whether we should fold this into the rebase case. My
concern is that if the user sees
cannot delete branch 'feature' because it is being rebased in the
worktree '../feature'
and then they do
cd ../feature
git status
they'll see a different branch name in the status output which is
confusing. So I think we either need to improve the status output to
show all the branches that are being rewritten (which to my mind is the
better option, it is more work but shouldn't be too difficult as it
already parses "rebase-merge/git-rebase-todo" and "rebase-merge/done"),
or say something like
cannot delete branch 'feature' because it is being updated by a
rebase running in '../feature' which is updating multiple branches.
for the update-refs case.
Thanks for working on this, it is a nice usability improvement.
Phillip
> Shortening a quite long expression down to digestable pieces is left
> as an exercise for those with this particular itch to scratch ;-).
> I do not personally mind if it ends up indistinguishable from other
> "rebase" case (or unified the "kind" enum into one), but others may
> have ideas to shorten the message to fit in the pattern we see
> above.
>
> Thanks.
prev parent reply other threads:[~2026-07-19 9:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-18 4:39 [PATCH] branch: report kind of checkout when rejecting delete René Scharfe
2026-07-18 17:34 ` Junio C Hamano
2026-07-18 19:07 ` René Scharfe
2026-07-18 22:09 ` Junio C Hamano
2026-07-19 5:55 ` René Scharfe
2026-07-19 9:50 ` Phillip Wood [this message]
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=03a332e0-afaa-4562-a503-2ff8a8f9f2ac@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=l.s.r@web.de \
--cc=phillip.wood@dunelm.org.uk \
--cc=ps@pks.im \
--cc=stsp2@yandex.ru \
--cc=toon@iotcl.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox