From: Yoichi Nakayama Date: Sat, 22 Aug 2026 00:50:48 GMT Subject: Re: [PATCH v6 3/3] worktree add: improve message for ambiguous remote branch name Message-ID: In-Reply-To: On Sat, Aug 22, 2026 at 8:49 AM Junio C Hamano wrote: > > Yoichi Nakayama writes: > > > My initial patch included a warning and advice here, > > but now I don't think they are necessary. > > > > Even if multiple remotes match here, the command completes > > successfully. This could well be the intended behavior > > (just as when there is no match). In that case, a warning > > or advice might be superfluous. > > In other words, there is no point in calling dwim_branch() from that > code path, as the end result is exactly the same whether no remotes > match, exactly one remote matches, or two or more remotes match? > Would it then make sense to leave a note there to consider later if > the dwim_branch() call can be removed? No. The exit codes of the command 'git worktree add ../topic-branch' are the same (== 0). but the results are different. If there is a unique match found in dwim_branch(), it creates a local branch named topic-branch which tracks /topic-branch. In case of no match or multiple matches, it creates a local branch named topic-branch from HEAD. Since Git treats both cases as successful, either can be considered the intended behavior. (Although, if there are multiple matches, there is a fair chance the result might not be what was intended.) I am confident that it is appropriate to provide a hint when a command fails, but it is difficult to decide what to do when a command succeeds. Thanks, -- Yoichi NAKAYAMA