Re: [RFC/PATCH] Add multiple workdir support to branch/checkout
- From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
- Date
- Oct 5, 2011, 04:02 UTC
- Message-ID
- <CACsJy8AqYq+YF+rvUp=BBeFUAtUz783iF2jbUp3fO58yLp9ptQ@mail.gmail.com>
- In-Reply-To
- <1317786204-57335-1-git-send-email-jaysoffian@gmail.com>
On Wed, Oct 5, 2011 at 2:43 PM, Jay Soffian <jaysoffian@gmail.com> wrote:
Show 14 quoted lines
> When using 'git new-workdir', there is no safety mechanism to prevent the > same branch from being checked out twice, nor to prevent a checked out > branch from being deleted. > > By teaching 'checkout' to record the workdir path using > 'branch.<name>.checkout' when switching branches, we can easily check if a > branch is already checked out in another workdir before switching to that > branch. Similarly, we can now add a check before deleting a branch. > > Allow 'checkout -f' to force the checkout and issue a warning > instead of an error. > > Guard this behavior behind 'core.recordCheckouts', which we will > teach 'git new-workdir' to set in a followup commit.
I've wanted to to something like this, but you beat me to it ;)
Could you please consider a more generic approach? What I have in mind is a mechanism to "lock" a branch, so that only commands that have the key can update it.
So instead of branch.<name>.checkout, I would have something like branch.<name>.locked = <key>, where <key> is just a string. Only commands that provide the matching <key> are allowed to update the branch. In checkout case, <key> could be "checkout: worktree".
This approach addresses more cases than just multiple workdir. We could relax restrictions on pushing to a non-bare repository: we only disallow pushing to locked branches. We can also use this to prevent users from checking out another branch (by locking HEAD) while in the middle of interactive rebase/bisect/...
-- Duy