From: Jasper Mayone <me@jaspermayone.com>
To: gitster@pobox.com, git@vger.kernel.org
Cc: phillip.wood123@gmail.com, --cc=sunshine@sunshineco.com,
--cc=kristofferhaugsbakk@fastmail.com, --cc=ben.knoble@gmail.com,
--cc=haraldnordgren@gmail.com,
Jasper Mayone <me@jaspermayone.com>
Subject: Re: [PATCH v5 1/5] worktree remove: refuse a worktree in the middle of an operation
Date: Mon, 16 Nov 2026 11:15:40 -0500 [thread overview]
Message-ID: <20261116161540.55855-1-me@jaspermayone.com> (raw)
In-Reply-To: <xmqqld6wblrm.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
> Having a central place like this is a very good design to keep it
> extensible. In addition to "git worktree remove", we have
> protection against checking out the same branch in multiple
> worktrees. How should this check interact with the checks done in
> that other code path, if any?
The two checks answer different questions, and I think they should
stay separate.
die_if_checked_out() asks "does another worktree hold this branch?".
It goes through is_shared_symref(), which uses
is_worktree_being_rebased() and is_worktree_being_bisected(), so it
only cares about a rebase or bisect that names a branch.
check_no_operation_in_progress() asks "would removing this worktree
lose state?". That is also true for a rebase of a detached HEAD, for
"git am", and for a cherry-pick or revert, which hold no branch.
They agree where they meet: while a worktree is rebasing "topic",
"git worktree remove" refuses it and "git checkout topic" elsewhere
refuses too. After "git worktree remove --force", the worktree is
gone, so the branch is free again.
You asked the same thing on [3/5], so I answer it here too. The
detection overlaps, but the result does not. There are now three
places that read the rebase and bisect state of a worktree:
prepare_checked_out_branches() in branch.c, the two
is_worktree_being_*() helpers in worktree.c, and this function.
prepare_checked_out_branches() records only branch names, so 1/5
cannot use it as it is: it would miss a detached rebase and "git am".
A helper in worktree.c that reports which operation a worktree is in,
and on which branch if any, could serve all three. That fits well
with the libification you describe below:
> In the longer term, I think it would make sense to create a single
> helper function that checks if the worktree is in discardable state
> (without dying. Just return an error code instead), call it from
> here, and have call(s) to die() here. Then move everything below
> the callchain to worktree.c one level up to libify.
>
> Not in a scope for this change, of course. #leftoverbits.
so I would prefer to do it as a separate series on top of this one,
if that is OK with you.
Thanks
Jasper
next prev parent reply other threads:[~2026-11-16 16:15 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 17:33 [RFC PATCH 0/1] worktree list: add --merged and --no-merged Jasper Mayone
2026-10-21 17:33 ` [RFC PATCH 1/1] " Jasper Mayone
2026-10-23 18:30 ` Junio C Hamano
2026-10-24 6:25 ` Eric Sunshine
2026-10-24 16:53 ` [PATCH v2] worktree list: add --branch to select worktrees by branch Jasper Mayone
2026-10-25 14:47 ` Phillip Wood
2026-10-26 11:02 ` Phillip Wood
2026-10-28 6:02 ` Eric Sunshine
2026-10-28 15:27 ` Junio C Hamano
2026-10-28 11:32 ` Kristoffer Haugsbakk
2026-10-29 4:46 ` Jasper Mayone
2026-10-29 5:01 ` Eric Sunshine
2026-10-29 11:14 ` Phillip Wood
2026-10-29 14:23 ` Ben Knoble
2026-10-29 16:10 ` Phillip Wood
2026-10-30 14:21 ` [PATCH 0/2] worktree: treat a branch being rebased or bisected as checked out Jasper Mayone
2026-10-30 14:21 ` [PATCH 1/2] worktree remove: refuse a worktree in the middle of a rebase or bisect Jasper Mayone
2026-11-02 14:07 ` Phillip Wood
2026-11-02 17:57 ` Jasper Mayone
2026-10-30 14:21 ` [PATCH 2/2] ref-filter: name the worktree of a branch being rebased or bisected Jasper Mayone
2026-11-02 14:06 ` Phillip Wood
2026-11-02 17:57 ` Jasper Mayone
2026-10-30 22:55 ` [PATCH 0/2] worktree: treat a branch being rebased or bisected as checked out Junio C Hamano
2026-10-30 23:06 ` Jasper Mayone
2026-11-02 18:29 ` [PATCH v4 0/4] " Jasper Mayone
2026-11-02 18:29 ` [PATCH v4 1/4] worktree remove: refuse a worktree in the middle of an operation Jasper Mayone
2026-11-10 16:47 ` Phillip Wood
2026-11-10 17:09 ` Ben Knoble
2026-11-02 18:29 ` [PATCH v4 2/4] doc: for-each-ref: say how to read %(worktreepath) safely Jasper Mayone
2026-11-09 12:36 ` D. Ben Knoble
2026-11-09 15:10 ` Phillip Wood
2026-11-09 17:27 ` Ben Knoble
2026-11-09 20:17 ` Junio C Hamano
2026-11-10 16:47 ` Phillip Wood
2026-11-02 18:29 ` [PATCH v4 3/4] ref-filter: name the worktree of a branch being rebased or bisected Jasper Mayone
2026-11-10 16:47 ` Phillip Wood
2026-11-02 18:29 ` [PATCH v4 4/4] branch: do not mark the branch the current worktree is rebasing Jasper Mayone
2026-11-10 16:45 ` Phillip Wood
2026-11-10 16:49 ` [PATCH v4 0/4] worktree: treat a branch being rebased or bisected as checked out Phillip Wood
2026-11-11 15:28 ` [PATCH v5 0/5] " Jasper Mayone
2026-11-11 15:28 ` [PATCH v5 1/5] worktree remove: refuse a worktree in the middle of an operation Jasper Mayone
2026-11-13 18:59 ` Junio C Hamano
2026-11-16 16:15 ` Jasper Mayone [this message]
2026-11-11 15:28 ` [PATCH v5 2/5] doc: for-each-ref: say how to read %(worktreepath) safely Jasper Mayone
2026-11-13 18:59 ` Junio C Hamano
2026-11-11 15:28 ` [PATCH v5 3/5] ref-filter: name the worktree of a branch being rebased or bisected Jasper Mayone
2026-11-13 18:59 ` Junio C Hamano
2026-11-11 15:28 ` [PATCH v5 4/5] ref-filter: add %(currentworktree) Jasper Mayone
2026-11-13 18:59 ` Junio C Hamano
2026-11-16 16:42 ` Phillip Wood
2026-11-11 15:28 ` [PATCH v5 5/5] branch: do not mark the branch the current worktree is rebasing Jasper Mayone
2026-11-13 18:59 ` Junio C Hamano
2026-11-16 16:15 ` Jasper Mayone
2026-11-11 15:42 ` [PATCH v5 0/5] worktree: treat a branch being rebased or bisected as checked out Ben Knoble
2026-10-21 21:36 ` [RFC PATCH 0/1] worktree list: add --merged and --no-merged Harald Nordgren
2026-10-21 22:12 ` Junio C Hamano
2026-10-22 7:21 ` Harald Nordgren
2026-10-22 17:58 ` Kristoffer Haugsbakk
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=20261116161540.55855-1-me@jaspermayone.com \
--to=me@jaspermayone.com \
--cc=--cc=ben.knoble@gmail.com \
--cc=--cc=haraldnordgren@gmail.com \
--cc=--cc=kristofferhaugsbakk@fastmail.com \
--cc=--cc=sunshine@sunshineco.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=phillip.wood123@gmail.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