Skip to content

pr-2197/yoichi/improve-worktree-add-error-message-v7

tagged this 22 Aug 03:22
'git worktree add ../foo-dir bar-topic' fails to dwim when there are
multiple remote branches with name `bar-topic'. But it doesn't display
meaningful message as 'git checkout bar-topic' does under the same
situation.

We improve this by adding advice and modify the error message for worktree
add.

By Junio's suggestion, we include matched remote names in the advice. It is
applied to checkout, too.

Changes from the previous patch:

 * fix grammatical errors in hints
 * narrow the scope of local variable oid

Yoichi NAKAYAMA (3):
  checkout: extract function to display advice for ambiguous remotes
  checkout: improve message for ambiguous remote branch name
  worktree add: improve message for ambiguous remote branch name

 builtin/checkout.c      | 76 +++++++++++++++++++++++++----------------
 builtin/worktree.c      | 39 ++++++++++++++++++---
 checkout.c              | 14 ++++++--
 checkout.h              |  5 ++-
 t/t2400-worktree-add.sh |  4 +--
 5 files changed, 99 insertions(+), 39 deletions(-)

base-commit: dea0ea3582e6980ddbc1173cc8e3e9f9db91cde0

Submitted-As: https://lore.kernel.org/git/pull.2197.v7.git.1787368962.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
In-Reply-To: https://lore.kernel.org/git/pull.2197.v3.git.1786395305884.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2197.v4.git.1786430155244.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2197.v5.git.1787143859.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2197.v6.git.1787259838.gitgitgadget@gmail.com
Assets 2
Loading