]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ab/push-dwim-dst'
authorJunio C Hamano <gitster@pobox.com>
Fri, 4 Jan 2019 21:33:33 +0000 (13:33 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 4 Jan 2019 21:33:34 +0000 (13:33 -0800)
"git push $there $src:$dst" rejects when $dst is not a fully
qualified refname and not clear what the end user meant.  The
codepath has been taught to give a clearer error message, and also
guess where the push should go by taking the type of the pushed
object into account (e.g. a tag object would want to go under
refs/tags/).

* ab/push-dwim-dst:
  push doc: document the DWYM behavior pushing to unqualified <dst>
  push: test that <src> doesn't DWYM if <dst> is unqualified
  push: add an advice on unqualified <dst> push
  push: move unqualified refname error into a function
  push: improve the error shown on unqualified <dst> push
  i18n: remote.c: mark error(...) messages for translation
  remote.c: add braces in anticipation of a follow-up change

1  2 
remote.c

diff --cc remote.c
index 70aba02c7453b8153b08a1f66852e5bae80707e6,f7477b8eb67a2065d6b0e35601a6be709b6d0931..670dd448130d20325f5f9f1de8afd0f011535db2
+++ b/remote.c
@@@ -1038,21 -1096,19 +1096,18 @@@ static int match_explicit(struct ref *s
        case 1:
                break;
        case 0:
-               if (starts_with(dst_value, "refs/"))
+               if (starts_with(dst_value, "refs/")) {
                        matched_dst = make_linked_ref(dst_value, dst_tail);
-               else if (is_null_oid(&matched_src->new_oid))
 -
+               } else if (is_null_oid(&matched_src->new_oid)) {
                        error(_("unable to delete '%s': remote ref does not exist"),
                              dst_value);
-               else if ((dst_guess = guess_ref(dst_value, matched_src))) {
+               else if ((dst_guess = guess_ref(dst_value, matched_src))) {
                        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);
+               } else {
+                       show_push_unqualified_ref_name_error(dst_value,
+                                                            matched_src->name);
+               }
                break;
        default:
                matched_dst = NULL;