On Fri, May 4, 2018 at 3:14 AM, Eric Sunshine <[email protected]> wrote:
> The setting up of a remote-tracking branch is DWIM'd as of 4e85333197
> ("worktree: make add <path> <branch> dwim", 2017-11-26); it doesn't
> require an explicit option to enable it (though tracking can be
> disabled via --no-track). The "guess-remote" feature does something
> entirely different; it was added to avoid backward compatibility
> problems.
>
> In long-form:
>
> git worktree add <path> <branch>
>
> adds a new worktree at <path> and checks out <branch>. As originally
> implemented, shortened:
>
> git worktree add <path>
>
> does one type of DWIM, as a convenience, and pretends that the user
> actually typed:
>
> branch=$(basename <path>)
> git branch $branch HEAD
> git workree add <path> $branch
This explanation isn't wrong, but it conflates two separate features,
thus is confusing. The $(basename <branch>) DWIM'ing from the short
form of the command, "git worktree add <path>", doesn't actually have
anything to do with the DWIM'ing added by 4e85333197 ("worktree: make
add <path> <branch> dwim", 2017-11-26), which merely tries to DWIM a
remote-tracking branch of similar name to $branch (whether $branch
came from long or short form of the command), so I confused the issue
unnecessarily by talking about the short form.