Re: [PATCH v1 2/2] worktree: make add dwim
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Nov 14, 2017, 20:29 UTC
- Message-ID
- <CAPig+cTDMvOWW2xLYfvQsOsfBuCOGDJwH_zRDQyxx1vpfkX4tA@mail.gmail.com>
- In-Reply-To
- <CAPig+cTYC01Y9-EvyNo9hxQRbT60iqp8MqXEB_zWBi14kPV1Ng@mail.gmail.com>
On Tue, Nov 14, 2017 at 3:14 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 6 quoted lines
> For my own edification... > [...] > git worktree add ../topic > > * Correctly errors out, refusing to create a new branch named "topic", > if "topic" is already a branch.
By the way, there's an additional DWIM that could be done here instead of erroring out. Specifically, for "git worktree add ../topic":
* If branch "topic" exists, check it out (rather than refusing to create a new branch named "topic").
* If origin/topic exists, DWIM local "topic" branch into existence.
* Otherwise, create new local branch "topic".
Show 6 quoted lines
> * Creates a new branch named "topic" if no such local branch exists. > > The desired new DWIMing would change the second bullet point to: > > * If no local branch named "topic" exists, DWIM it from "origin/topic" > if possible, else create a new local branch named "topic".