]> git.ipfire.org Git - thirdparty/git.git/blobdiff - refs.c
refs: print error message in debug output
[thirdparty/git.git] / refs.c
diff --git a/refs.c b/refs.c
index 996ac2716417de5e84f919782091d03ff75624b0..4c317955813a67222be95c16b337cb55f1a07326 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -1083,9 +1083,10 @@ int ref_transaction_update(struct ref_transaction *transaction,
 {
        assert(err);
 
-       if ((new_oid && !is_null_oid(new_oid)) ?
-           check_refname_format(refname, REFNAME_ALLOW_ONELEVEL) :
-           !refname_is_safe(refname)) {
+       if (!(flags & REF_SKIP_REFNAME_VERIFICATION) &&
+           ((new_oid && !is_null_oid(new_oid)) ?
+                    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;
@@ -1094,6 +1095,13 @@ int ref_transaction_update(struct ref_transaction *transaction,
        if (flags & ~REF_TRANSACTION_UPDATE_ALLOWED_FLAGS)
                BUG("illegal flags 0x%x passed to ref_transaction_update()", flags);
 
+       /*
+        * Clear flags outside the allowed set; this should be a noop because
+        * of the BUG() check above, but it works around a -Wnonnull warning
+        * with some versions of "gcc -O3".
+        */
+       flags &= REF_TRANSACTION_UPDATE_ALLOWED_FLAGS;
+
        flags |= (new_oid ? REF_HAVE_NEW : 0) | (old_oid ? REF_HAVE_OLD : 0);
 
        ref_transaction_add_update(transaction, refname, flags,
@@ -2366,16 +2374,15 @@ int reflog_exists(const char *refname)
 }
 
 int refs_create_reflog(struct ref_store *refs, const char *refname,
-                      int force_create, struct strbuf *err)
+                      struct strbuf *err)
 {
-       return refs->be->create_reflog(refs, refname, force_create, err);
+       return refs->be->create_reflog(refs, refname, err);
 }
 
-int safe_create_reflog(const char *refname, int force_create,
-                      struct strbuf *err)
+int safe_create_reflog(const char *refname, struct strbuf *err)
 {
        return refs_create_reflog(get_main_ref_store(the_repository), refname,
-                                 force_create, err);
+                                 err);
 }
 
 int refs_delete_reflog(struct ref_store *refs, const char *refname)