pr-2197/yoichi/improve-worktree-add-error-message-v3
tagged this
10 Aug 20:55
From: Yoichi NAKAYAMA <yoichi.nakayama@gmail.com> When the user runs 'git worktree add x y' command that does not exactly say which remote they want to work with, and there is no local branch named y, we try to guess which remote by passing y then create a new branch named y which tracks the remote branch. If there are multiple remotes that have branch named y, we silently gave up, leaving the variable branch intact. This later causes creating local branch and worktree not happen, and we end up with passing an non-existing branch to lookup_commit_reference_by_name(), triggering "invalid reference" error and die. To resolve this issue, display a hint and a descriptive error message and die immediately when multiple mathing branches are found. Signed-off-by: Yoichi NAKAYAMA <yoichi.nakayama@gmail.com> Submitted-As: https://lore.kernel.org/git/pull.2197.v3.git.1786395305884.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2197.git.1786177301832.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2197.v2.git.1786374470383.gitgitgadget@gmail.com