Merge branch 'tg/refs-allowed-flags' into maint
authorJunio C Hamano <gitster@pobox.com>
Wed, 18 Oct 2017 05:18:58 +0000 (14:18 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 18 Oct 2017 05:18:59 +0000 (14:18 +0900)
API error-proofing which happens to also squelch warnings from GCC.

* tg/refs-allowed-flags:
refs: strip out not allowed flags from ref_transaction_update

refs.c
refs.h
diff --git a/refs.c b/refs.c
index ea2b9f84f8d3fab5452105f10f4492d672cd1d90..41aec6505d1309fa2efed2bd9aca0a0ef2646444 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -921,6 +921,8 @@ int ref_transaction_update(struct ref_transaction *transaction,
                return -1;
        }
 
+       flags &= REF_TRANSACTION_UPDATE_ALLOWED_FLAGS;
+
        flags |= (new_sha1 ? REF_HAVE_NEW : 0) | (old_sha1 ? REF_HAVE_OLD : 0);
 
        ref_transaction_add_update(transaction, refname, flags,
diff --git a/refs.h b/refs.h
index 6daa78eb50ddc195c6d5bfb568d0b05ab08f7923..4d75c207e18bd6504a5613a373adf9dd8c745034 100644 (file)
--- a/refs.h
+++ b/refs.h
@@ -354,6 +354,14 @@ int refs_pack_refs(struct ref_store *refs, unsigned int flags);
 #define REF_NODEREF    0x01
 #define REF_FORCE_CREATE_REFLOG 0x40
 
+/*
+ * Flags that can be passed in to ref_transaction_update
+ */
+#define REF_TRANSACTION_UPDATE_ALLOWED_FLAGS \
+       REF_ISPRUNING |                      \
+       REF_FORCE_CREATE_REFLOG |            \
+       REF_NODEREF
+
 /*
  * Setup reflog before using. Fill in err and return -1 on failure.
  */