ref_transaction_update(): check refname_is_safe() at a minimum
[git/git.git] / refs.c
diff --git a/refs.c b/refs.c
index 7c4eeb1..842c5c7 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -805,8 +805,9 @@ int ref_transaction_update(struct ref_transaction *transaction,
 {
        assert(err);
 
-       if (new_sha1 && !is_null_sha1(new_sha1) &&
-           check_refname_format(refname, REFNAME_ALLOW_ONELEVEL)) {
+       if ((new_sha1 && !is_null_sha1(new_sha1)) ?
+           check_refname_format(refname, REFNAME_ALLOW_ONELEVEL) :
+           !refname_is_safe(refname)) {
                strbuf_addf(err, "refusing to update ref with bad name '%s'",
                            refname);
                return -1;