push: move unqualified refname error into a function

A follow-up change will extend this error message with the advice facility. Doing so would make the indentation too deeply nested for comfort. So let's split this into a helper function. There's no changes to the wording here. Just code moving & re-indentation, and re-flowing the "TRANSLATORS" comment. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Nov 13, 2018 at 19:52 UTC 04d17287a0e0161e5a0accd8ab781135bd672c98
1 file changed +22 -16
remote.c
+22 -16
@@ -1005,6 +1005,26 @@ static int match_explicit_lhs(struct ref *src,
1005 }
1006 }
1007
1008 +static void show_push_unqualified_ref_name_error(const char *dst_value,
1009 + const char *matched_src_name)
1010 +{
1011 + /*
1012 + * TRANSLATORS: "matches '%s'%" is the <dst> part of "git push
1013 + * <remote> <src>:<dst>" push, and "being pushed ('%s')" is
1014 + * the <src>.
1015 + */
1016 + error(_("The destination you provided is not a full refname (i.e.,\n"
1017 + "starting with \"refs/\"). We tried to guess what you meant by:\n"
1018 + "\n"
1019 + "- Looking for a ref that matches '%s' on the remote side.\n"
1020 + "- Checking if the <src> being pushed ('%s')\n"
1021 + " is a ref in \"refs/{heads,tags}/\". If so we add a corresponding\n"
1022 + " refs/{heads,tags}/ prefix on the remote side.\n"
1023 + "\n"
1024 + "Neither worked, so we gave up. You must fully qualify the ref."),
1025 + dst_value, matched_src_name);
1026 +}
1027 +
1028 static int match_explicit(struct ref *src, struct ref *dst,
1029 struct ref ***dst_tail,
1030 struct refspec_item *rs)
@@ -1049,22 +1069,8 @@ static int match_explicit(struct ref *src, struct ref *dst,
1069 matched_dst = make_linked_ref(dst_guess, dst_tail);
1070 free(dst_guess);
1071 } else {
1052 - /*
1053 - * TRANSLATORS: "matches '%s'%" is the <dst>
1054 - * part of "git push <remote> <src>:<dst>"
1055 - * push, and "being pushed ('%s')" is the
1056 - * <src>.
1057 - */
1058 - error(_("The destination you provided is not a full refname (i.e.,\n"
1059 - "starting with \"refs/\"). We tried to guess what you meant by:\n"
1060 - "\n"
1061 - "- Looking for a ref that matches '%s' on the remote side.\n"
1062 - "- Checking if the <src> being pushed ('%s')\n"
1063 - " is a ref in \"refs/{heads,tags}/\". If so we add a corresponding\n"
1064 - " refs/{heads,tags}/ prefix on the remote side.\n"
1065 - "\n"
1066 - "Neither worked, so we gave up. You must fully qualify the ref."),
1067 - dst_value, matched_src->name);
1072 + show_push_unqualified_ref_name_error(dst_value,
1073 + matched_src->name);
1074 }
1075 break;
1076 default: