1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-09 10:36:09 +02:00
git/refs
Michael Haggerty 30173b8851 ref_transaction_prepare(): new optional step for reference updates
In the future, compound reference stores will sometimes need to modify
references in two different reference stores at the same time, meaning
that a single logical reference transaction might have to be
implemented as two internal sub-transactions. They won't want to call
`ref_transaction_commit()` for the two sub-transactions one after the
other, because that wouldn't be atomic (the first commit could succeed
and the second one fail). Instead, they will want to prepare both
sub-transactions (i.e., obtain any necessary locks and do any
pre-checks), and only if both prepare steps succeed, then commit both
sub-transactions.

Start preparing for that day by adding a new, optional
`ref_transaction_prepare()` step to the reference transaction
sequence, which obtains the locks and does any prechecks, reporting
any errors that occur. Also add a `ref_transaction_abort()` function
that can be used to abort a sub-transaction even if it has already
been prepared.

That is on the side of the public-facing API. On the side of the
`ref_store` VTABLE, get rid of `transaction_commit` and instead add
methods `transaction_prepare`, `transaction_finish`, and
`transaction_abort`. A `ref_transaction_commit()` now basically calls
methods `transaction_prepare` then `transaction_finish`.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-23 14:29:55 +09:00
..
files-backend.c ref_transaction_prepare(): new optional step for reference updates 2017-05-23 14:29:55 +09:00
iterator.c prefix_ref_iterator: don't trim too much 2017-05-23 14:29:52 +09:00
ref-cache.c refs/files-backend: convert many internals to struct object_id 2017-05-08 15:12:58 +09:00
ref-cache.h refs/files-backend: convert many internals to struct object_id 2017-05-08 15:12:58 +09:00
refs-internal.h ref_transaction_prepare(): new optional step for reference updates 2017-05-23 14:29:55 +09:00