Skip to content

Commit 04d1728

Browse files
avargitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c83cca3 commit 04d1728

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

remote.c

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,26 @@ static int match_explicit_lhs(struct ref *src,
10051005
}
10061006
}
10071007

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+
10081028
static int match_explicit(struct ref *src, struct ref *dst,
10091029
struct ref ***dst_tail,
10101030
struct refspec_item *rs)
@@ -1049,22 +1069,8 @@ static int match_explicit(struct ref *src, struct ref *dst,
10491069
matched_dst = make_linked_ref(dst_guess, dst_tail);
10501070
free(dst_guess);
10511071
} 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);
10681074
}
10691075
break;
10701076
default:

0 commit comments

Comments
 (0)