summaryrefslogtreecommitdiff
path: root/remote.c
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2018-11-13 19:52:41 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-11-14 06:27:55 (GMT)
commitc83cca3f74f3fcc28b9742a92720bea8a1c3915c (patch)
tree1f6866331a4780a3862de51b85e98611c0adf071 /remote.c
parent8b0e5429120f73d37c275fca9ace8b3de4056b2f (diff)
downloadgit-c83cca3f74f3fcc28b9742a92720bea8a1c3915c.zip
git-c83cca3f74f3fcc28b9742a92720bea8a1c3915c.tar.gz
git-c83cca3f74f3fcc28b9742a92720bea8a1c3915c.tar.bz2
push: improve the error shown on unqualified <dst> push
Improve the error message added in f8aae12034 ("push: allow unqualified dest refspecs to DWIM", 2008-04-23), which before this change looks like this: $ git push avar v2.19.0^{commit}:newbranch -n error: unable to push to unqualified destination: newbranch The destination refspec neither matches an existing ref on the remote nor begins with refs/, and we are unable to guess a prefix based on the source ref. error: failed to push some refs to 'git@github.com:avar/git.git' This message needed to be read very carefully to spot how to fix the error, i.e. to push to refs/heads/newbranch. Now the message will look like this instead: $ ./git-push avar v2.19.0^{commit}:newbranch -n error: The destination you provided is not a full refname (i.e., starting with "refs/"). We tried to guess what you meant by: - Looking for a ref that matches 'newbranch' on the remote side. - Checking if the <src> being pushed ('v2.19.0^{commit}') is a ref in "refs/{heads,tags}/". If so we add a corresponding refs/{heads,tags}/ prefix on the remote side. Neither worked, so we gave up. You must fully qualify the ref. error: failed to push some refs to 'git@github.com:avar/git.git' This improvement is the result of on-list discussion in [1] and [2], as well as my own fixes / reformatting / phrasing on top. The suggestion by Jeff on-list was to make that second bullet point "Looking at the refname of the local source.". The version being added here is more verbose, but also more accurate. saying "local source" could refer to any ref in the local refstore, including something in refs/remotes/*. A later change will teach guess_ref() to infer a ref type from remote-tracking refs, so let's not confuse the two. While I'm at it, add a "TRANSLATORS" comment since the message has gotten more complex and it's not as clear what the two %s's refer to. 1. https://public-inbox.org/git/20181010205505.GB12949@sigill.intra.peff.net/ 2. https://public-inbox.org/git/xmqqbm81lb7c.fsf@gitster-ct.c.googlers.com/ Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'remote.c')
-rw-r--r--remote.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/remote.c b/remote.c
index 35fe8a1..15da401 100644
--- a/remote.c
+++ b/remote.c
@@ -1049,12 +1049,22 @@ static int match_explicit(struct ref *src, struct ref *dst,
matched_dst = make_linked_ref(dst_guess, dst_tail);
free(dst_guess);
} else {
- error(_("unable to push to unqualified destination: %s\n"
- "The destination refspec neither matches an "
- "existing ref on the remote nor\n"
- "begins with refs/, and we are unable to "
- "guess a prefix based on the source ref."),
- dst_value);
+ /*
+ * TRANSLATORS: "matches '%s'%" is the <dst>
+ * part of "git push <remote> <src>:<dst>"
+ * push, and "being pushed ('%s')" is the
+ * <src>.
+ */
+ error(_("The destination you provided is not a full refname (i.e.,\n"
+ "starting with \"refs/\"). We tried to guess what you meant by:\n"
+ "\n"
+ "- Looking for a ref that matches '%s' on the remote side.\n"
+ "- Checking if the <src> being pushed ('%s')\n"
+ " is a ref in \"refs/{heads,tags}/\". If so we add a corresponding\n"
+ " refs/{heads,tags}/ prefix on the remote side.\n"
+ "\n"
+ "Neither worked, so we gave up. You must fully qualify the ref."),
+ dst_value, matched_src->name);
}
break;
default: