From: Junio C Hamano Date: Fri, 4 Jan 2019 21:33:33 +0000 (-0800) Subject: Merge branch 'ab/push-dwim-dst' X-Git-Tag: v2.21.0-rc0~129 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/0a84724bf8ed1240b61e2401aec8a6cab93111b1 Merge branch 'ab/push-dwim-dst' "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 push: test that doesn't DWYM if is unqualified push: add an advice on unqualified push push: move unqualified refname error into a function push: improve the error shown on unqualified push i18n: remote.c: mark error(...) messages for translation remote.c: add braces in anticipation of a follow-up change --- 0a84724bf8ed1240b61e2401aec8a6cab93111b1 diff --cc remote.c index 70aba02c74,f7477b8eb6..670dd44813 --- a/remote.c +++ 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;