refs: mark invalid refname message for translation
The error message produced by `transaction_refname_valid()` changes based on whether the update is a ref update or a reflog update, with the use of a ternary operator. This breaks translation since the sub-msg is not marked for translation. Fix this by setting the entire message using a `if {} else {}` block and marking each message for translation. Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Karthik Nayak committed
Dec 20, 2024 at 13:58 UTC
8ddcdc1bb33ccf803461dd2365146f9341bf9312
1 file changed
+12
-4
refs.c
+12
-4
@@ -1208,14 +1208,22 @@ static int transaction_refname_valid(const char *refname,
1208
return 1;
1209
1210
if (is_pseudo_ref(refname)) {
1211
- const char *what = flags & REF_LOG_ONLY ? "reflog for pseudoref" : "pseudoref";
1212
- strbuf_addf(err, _("refusing to update %s '%s'"), what, refname);
1211
+ const char *refusal_msg;
1212
+ if (flags & REF_LOG_ONLY)
1213
+ refusal_msg = _("refusing to update reflog for pseudoref '%s'");
1214
+ else
1215
+ refusal_msg = _("refusing to update pseudoref '%s'");
1216
+ strbuf_addf(err, refusal_msg, refname);
1217
return 0;
1218
} else if ((new_oid && !is_null_oid(new_oid)) ?
1219
check_refname_format(refname, REFNAME_ALLOW_ONELEVEL) :
1220
!refname_is_safe(refname)) {
1217
- const char *what = flags & REF_LOG_ONLY ? "reflog with bad name" : "ref with bad name";
1218
- strbuf_addf(err, _("refusing to update %s '%s'"), what, refname);
1221
+ const char *refusal_msg;
1222
+ if (flags & REF_LOG_ONLY)
1223
+ refusal_msg = _("refusing to update reflog with bad name '%s'");
1224
+ else
1225
+ refusal_msg = _("refusing to update ref with bad name '%s'");
1226
+ strbuf_addf(err, refusal_msg, refname);
1227
return 0;
1228
}
1229