Re: [PATCH 2/2] checkout: forbid "-B <branch>" from touching a branch used elsewhere
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Nov 23, 2023, 17:09 UTC
- Message-ID
- <CAPig+cRdQW-DG8PFb-P0U_44pFWxskVoOtjbGfD_OiHHDk8DdA@mail.gmail.com>
- In-Reply-To
- <bf848477-b4dd-49d3-8e4b-de0fc3948570@gmail.com>
On Thu, Nov 23, 2023 at 11:33 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
Show 17 quoted lines
> On 23/11/2023 06:00, Junio C Hamano wrote: > > "git checkout -B <branch> [<start-point>]", being a "forced" version > > of "-b", switches to the <branch>, after optionally resetting its > > tip to the <start-point>, even if the <branch> is in use in another > > worktree, which is somewhat unexpected. > > > > Protect the <branch> using the same logic that forbids "git checkout > > <branch>" from touching a branch that is in use elsewhere. > > > > This is a breaking change that may deserve backward compatibliity > > warning in the Release Notes. The "--ignore-other-worktrees" option > > can be used as an escape hatch if the finger memory of existing > > users depend on the current behaviour of "-B". > > I think this change makes sense and I found the implementation here much > easier to understand than a previous attempt at > https://lore.kernel.org/git/20230120113553.24655-1-carenas@gmail.com/
Thanks for digging up this link. Upon reading the problem report, I felt certain that we had seen this issue reported previously and that patches had been proposed, but I was unable to find the conversation (despite having taken part in it).
I agree, also, that this two-patch series is simple to digest.