refs: allow passing flags when beginning transactions
We do not currently have any flags when creating reference transactions, but we'll add one to disable execution of the reference transaction hook in some cases. Allow passing flags to `ref_store_transaction_begin()` to prepare for this change. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
69840cc0f7
commit
fbe73f61cb
8
refs.c
8
refs.c
@ -800,7 +800,7 @@ int refs_delete_ref(struct ref_store *refs, const char *msg,
|
||||
struct ref_transaction *transaction;
|
||||
struct strbuf err = STRBUF_INIT;
|
||||
|
||||
transaction = ref_store_transaction_begin(refs, &err);
|
||||
transaction = ref_store_transaction_begin(refs, 0, &err);
|
||||
if (!transaction ||
|
||||
ref_transaction_delete(transaction, refname, old_oid,
|
||||
flags, msg, &err) ||
|
||||
@ -1005,6 +1005,7 @@ int read_ref_at(struct ref_store *refs, const char *refname,
|
||||
}
|
||||
|
||||
struct ref_transaction *ref_store_transaction_begin(struct ref_store *refs,
|
||||
unsigned int flags,
|
||||
struct strbuf *err)
|
||||
{
|
||||
struct ref_transaction *tr;
|
||||
@ -1012,12 +1013,13 @@ struct ref_transaction *ref_store_transaction_begin(struct ref_store *refs,
|
||||
|
||||
CALLOC_ARRAY(tr, 1);
|
||||
tr->ref_store = refs;
|
||||
tr->flags = flags;
|
||||
return tr;
|
||||
}
|
||||
|
||||
struct ref_transaction *ref_transaction_begin(struct strbuf *err)
|
||||
{
|
||||
return ref_store_transaction_begin(get_main_ref_store(the_repository), err);
|
||||
return ref_store_transaction_begin(get_main_ref_store(the_repository), 0, err);
|
||||
}
|
||||
|
||||
void ref_transaction_free(struct ref_transaction *transaction)
|
||||
@ -1156,7 +1158,7 @@ int refs_update_ref(struct ref_store *refs, const char *msg,
|
||||
struct strbuf err = STRBUF_INIT;
|
||||
int ret = 0;
|
||||
|
||||
t = ref_store_transaction_begin(refs, &err);
|
||||
t = ref_store_transaction_begin(refs, 0, &err);
|
||||
if (!t ||
|
||||
ref_transaction_update(t, refname, new_oid, old_oid, flags, msg,
|
||||
&err) ||
|
||||
|
Reference in New Issue
Block a user