Re: [RFC/PATCH] worktree: replace "checkout --to" with "worktree new"
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Jul 2, 2015, 19:19 UTC
- Message-ID
- <CAPig+cSBimLTn5_6AmjLndoevVN80AOTzHj6bXOq2MS47zimkg@mail.gmail.com>
- In-Reply-To
- <CAPig+cTm7Qzxr_E+_p6UYmPrsQzTFCN-Mouu-FigNqRH=gSPKg@mail.gmail.com>
On Thu, Jul 2, 2015 at 3:00 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 26 quoted lines
> On Thu, Jul 2, 2015 at 2:45 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
>> There's another instance: 3473ad0 (checkout: don't require a work tree
>> when checking out into a new one, 2014-11-30) added this:
>>
>> if (!new_worktree)
>> setup_work_tree();
>>
>> which the "worktree add" patch changed to:
>>
>> setup_work_tree();
>>
>> which doesn't hurt (since setup_work_tree() protects itself against
>> multiple invocations) but isn't semantically clean. If I understand
>> correctly, I think a better approach would be to move the
>> setup_work_tree() call to worktree.c just before it invokes
>> git-checkout, and revert 3473ad0 entirely (including this bit):
>>
>> - { "checkout", cmd_checkout, RUN_SETUP | NEED_WORK_TREE },
>> +{ "checkout", cmd_checkout, RUN_SETUP },
>>
>> so that git-checkout once again requires a worktree.
>
> I mis-stated that a bit. The bit about "multiple invocations" isn't
> relevant. The point is that I think that 3473ad0 can simply be
> reverted as long as worktree.c calls setup_work_tree() before invoking
> git-checkout.Please ignore my idiocy. Of course worktree.c can't call setup_work_tree() on behalf of the sub git-checkout invocation. Reverting 3473ad0 is the correct thing to do with the introduction of "worktree add" since it removes the special case of having to be able to run git-checkout without a worktree.