Skip to content

Commit 8ddcdc1

Browse files
KarthikNayakgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 246cebe commit 8ddcdc1

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

refs.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,14 +1208,22 @@ static int transaction_refname_valid(const char *refname,
12081208
return 1;
12091209

12101210
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);
12131217
return 0;
12141218
} else if ((new_oid && !is_null_oid(new_oid)) ?
12151219
check_refname_format(refname, REFNAME_ALLOW_ONELEVEL) :
12161220
!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);
12191227
return 0;
12201228
}
12211229

0 commit comments

Comments
 (0)