On Wed, Jul 1, 2015 at 9:07 PM, Duy Nguyen <pclouds@xxxxxxxxx> wrote: > On Thu, Jul 2, 2015 at 12:13 AM, Eric Sunshine <sunshine@xxxxxxxxxxxxxx> wrote: >>> 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. 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"); merge_working_tree: tree = parse_tree_indirect(old->commit && !opts->new_worktree_mode ? old->commit->object.sha1 : EMPTY_TREE_SHA1_BIN); switch_branches: if (!opts->quiet && !old.path && old.commit && new->commit != old.commit && !opts->new_worktree_mode) orphaned_commit_warning(old.commit, new->commit); -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html