Re: [PATCH v5 7/8] checkout: add advice for ambiguous "checkout <branch>"
From: Eric Sunshine <hidden>
Date: 2018-06-01 22:52:36
On Fri, Jun 1, 2018 at 5:10 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 ands/and/add/
another remote (e.g. a fork) git won't find a unique branch name
Missing comma: s/)/),/
anymore, and will instead print this nondescript message:
Perhaps s/nondescript/unhelpful/ ?
$ 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: If you meant to check out a remote tracking branch on e.g. 'origin'Missing commas: s/on e.g. 'origin'/on, e.g. 'origin',/
hint: you can do so by fully-qualifying the name with the --track option:
s/fully-qualifying/fully qualifying/
hint:
hint: git checkout --track origin/<name>
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>Aside from the s/and/add/ botch, all of the above are tiny nits which don't actually impact the meaning of the commit message, thus not really important.
quoted hunk ↗ jump to hunk
---diff --git a/builtin/checkout.c b/builtin/checkout.c@@ -1267,6 +1268,18 @@ 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"
You could drop "The argument" prefix, without hurting the meaning at all, in order to gain a bit more horizontal space for the '%s' interpolation. (Not worth a re-roll.)
+ "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" + "If you meant to check out a remote tracking branch on e.g. 'origin'\n" + "you can do so by fully-qualifying the name with the --track option:\n" + "\n" + " git checkout --track origin/<name>"), + argv[0], + dwim_remotes_matched);