lock_ref_for_update(): make error handling more uniform
[gitweb.git] / refs.c
diff --git a/refs.c b/refs.c
index 7c4eeb1c99ec324ce898a66309a1215982e1a0b5..842c5c7b0543ea21da3b46e9ad588cf587cb91e6 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;