Re: [RFC/PATCH] worktree: replace "checkout --to" with "worktree new"
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Jul 2, 2015, 16:59 UTC
- Message-ID
- <CAPig+cS+4cbSNZJEHMoj+NRRt3N2guUH_byMb=k9QHeNS--SqQ@mail.gmail.com>
- In-Reply-To
- <CACsJy8Dce4ErwaRM7zTgLmRzcHxKOr4J8St46urettr5R4DbVg@mail.gmail.com>
On Thu, Jul 2, 2015 at 8:41 AM, Duy Nguyen <pclouds@gmail.com> wrote:
Show 13 quoted lines
> On Thu, Jul 2, 2015 at 9:52 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
>> The recursion protection is indeed no longer needed and gets removed
>> by the "worktree add" patch. However, there are still a few bits of
>> code which want to know that the checkout is happening in a new
>> worktree. I haven't examined them closely yet to diagnose if this
>> specialized knowledge can be eliminated. Perhaps you can weight in. In
>> particular:
>>
>> checkout_paths:
>> if (opts->new_worktree)
>> die(_("'%s' cannot be used with updating paths"), "--to");
>
> This one is easy, as "--to" is gone, no reason to report anything about "--to"In the "worktree add" patch, I kept this one (with s/--to/worktree add/) assuming that your intention was that a new worktree should never start with a partial checkout due to specifying paths. Looking at it more closely, I'm still not convinced that it can be removed. Given:
git worktree new <path> <branch> -- <file>
it creates <path> and checks out <file> (and only <file>) into <path>, however, the resulting worktree is "not on any branch". The latter, I think is because switch_branches() doesn't get called in this case; instead, it's just at whatever HEAD was faked up to appease is_git_directory().