Re: [RFC/PATCH] worktree: replace "checkout --to" with "worktree new"
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Jul 2, 2015, 01:07 UTC
- Message-ID
- <CACsJy8BdvLiM8Ki=N1k-fBrqqoEONhjwcN6jzGUk=3NPRRujQw@mail.gmail.com>
- In-Reply-To
- <CAPig+cRLpJK-C7MApH1vigZS=gmHNeo6RL3S2wXv4B-TFfnq4g@mail.gmail.com>
On Thu, Jul 2, 2015 at 12:13 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 13 quoted lines
>> I noticed GIT_CHECKOUT_NEW_WORKTREE environment variabl that does >> not seem to be documented. Is this something we still need? >> The log message of 529fef20 (checkout: support checking out into >> a new working directory, 2014-11-30) does not tell us much. > > Yes, it's still used for the same purpose as before the conversion: as > a private signal to the sub git-checkout invocation that it's > operating on a new worktree. When defined, it sets the > 'new_worktree_mode' flag in checkout.c, and there are still a few bits > of code which apparently need to know about it. It would be nice to > eliminate this special knowledge from checkout.c, however, I'm not yet > familiar enough with the checkout code to determine if doing so is > viable.
I think it can go away. When "--to" is used, I have to re-execute "git checkout" command again after creating the new worktree. I could process the command line arguments from the first execution, delete "--to", then use the remaining options to run checkout the second time. But I chose to pass the entire command line to the second execution. The env is used to let the second run know it should ignore "--to" (or we get infinite recursion). With "git worktree add" this recursion disappears and this env var has no reason to exist.
-- Duy