Re: [PATCH v4 8/9] checkout: add advice for ambiguous "checkout <branch>"
From: Eric Sunshine <hidden>
Date: 2018-06-01 07:53:20
On Thu, May 31, 2018 at 3:52 PM, Ævar Arnfjörð Bjarmason [off-list ref] wrote:
As the "checkout" documentation describes:
If <branch> is not found but there does exist a tracking branch in
exactly one remote (call it <remote>) with a matching name, treat
as equivalent to [...] <remote>/<branch.
This is a really useful feature, the problem is that when you anothers/, the/. The/ s/you/& add/
remote (e.g. a fork) git won't find a unique branch name anymore, and
will instead print this nondescript message:
$ git checkout master
error: pathspec 'master' did not match any file(s) known to git
Now it will, on my git.git checkout, print:
$ ./git --exec-path=$PWD checkout master
error: pathspec 'master' did not match any file(s) known to git.
hint: The argument 'master' matched more than one remote tracking branch.
hint: We found 26 remotes with a reference that matched. So we fell back
hint: on trying to resolve the argument as a path, but failed there too!
hint:
hint: Perhaps you meant fully qualify the branch name? E.g. origin/<name>s/meant/& to/
quoted hunk ↗ jump to hunk
hint: instead of <name>? Signed-off-by: Ævar Arnfjörð Bjarmason <redacted> ---diff --git a/builtin/checkout.c b/builtin/checkout.c@@ -1269,6 +1270,16 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) + if (ret && dwim_remotes_matched > 1 && + advice_checkout_ambiguous_remote_branch_name) + advise(_("The argument '%s' matched more than one remote tracking branch.\n" + "We found %d remotes with a reference that matched. So we fell back\n" + "on trying to resolve the argument as a path, but failed there too!\n" + "\n" + "Perhaps you meant fully qualify the branch name? E.g. origin/<name>\n"
s/meant/& to/
+ "instead of <name>?"),