]> git.ipfire.org Git - thirdparty/git.git/commitdiff
refs: mark invalid refname message for translation
authorKarthik Nayak <karthik.188@gmail.com>
Fri, 20 Dec 2024 12:58:37 +0000 (13:58 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 20 Dec 2024 15:52:44 +0000 (07:52 -0800)
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>
refs.c

diff --git a/refs.c b/refs.c
index 5d541ddc41aa84905e688c92565aa18fbf55323b..c55583986940d8ef1e1c839364c03cd92d4f7114 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -1208,14 +1208,22 @@ static int transaction_refname_valid(const char *refname,
                return 1;
 
        if (is_pseudo_ref(refname)) {
-               const char *what = flags & REF_LOG_ONLY ? "reflog for pseudoref" : "pseudoref";
-               strbuf_addf(err, _("refusing to update %s '%s'"), what, refname);
+               const char *refusal_msg;
+               if (flags & REF_LOG_ONLY)
+                       refusal_msg = _("refusing to update reflog for pseudoref '%s'");
+               else
+                       refusal_msg = _("refusing to update pseudoref '%s'");
+               strbuf_addf(err, refusal_msg, refname);
                return 0;
        } else if ((new_oid && !is_null_oid(new_oid)) ?
                 check_refname_format(refname, REFNAME_ALLOW_ONELEVEL) :
                 !refname_is_safe(refname)) {
-               const char *what = flags & REF_LOG_ONLY ? "reflog with bad name" : "ref with bad name";
-               strbuf_addf(err, _("refusing to update %s '%s'"), what, refname);
+               const char *refusal_msg;
+               if (flags & REF_LOG_ONLY)
+                       refusal_msg = _("refusing to update reflog with bad name '%s'");
+               else
+                       refusal_msg = _("refusing to update ref with bad name '%s'");
+               strbuf_addf(err, refusal_msg, refname);
                return 0;
        }