Merge branch 'rs/ref-transaction-1'
The second batch of the transactional ref update series. * rs/ref-transaction-1: (22 commits) update-ref --stdin: pass transaction around explicitly update-ref --stdin: narrow scope of err strbuf refs.c: make delete_ref use a transaction refs.c: make prune_ref use a transaction to delete the ref refs.c: remove lock_ref_sha1 refs.c: remove the update_ref_write function refs.c: remove the update_ref_lock function refs.c: make lock_ref_sha1 static walker.c: use ref transaction for ref updates fast-import.c: use a ref transaction when dumping tags receive-pack.c: use a reference transaction for updating the refs refs.c: change update_ref to use a transaction branch.c: use ref transaction for all ref updates fast-import.c: change update_branch to use ref transactions sequencer.c: use ref transactions for all ref updates commit.c: use ref transactions for updates replace.c: use the ref transaction functions for updates tag.c: use ref transactions when doing updates refs.c: add transaction.status and track OPEN/CLOSED refs.c: make ref_transaction_begin take an err argument ...
This commit is contained in:
@ -155,7 +155,8 @@ static int replace_object_sha1(const char *object_ref,
|
||||
unsigned char prev[20];
|
||||
enum object_type obj_type, repl_type;
|
||||
char ref[PATH_MAX];
|
||||
struct ref_lock *lock;
|
||||
struct ref_transaction *transaction;
|
||||
struct strbuf err = STRBUF_INIT;
|
||||
|
||||
obj_type = sha1_object_info(object, NULL);
|
||||
repl_type = sha1_object_info(repl, NULL);
|
||||
@ -168,12 +169,13 @@ static int replace_object_sha1(const char *object_ref,
|
||||
|
||||
check_ref_valid(object, prev, ref, sizeof(ref), force);
|
||||
|
||||
lock = lock_any_ref_for_update(ref, prev, 0, NULL);
|
||||
if (!lock)
|
||||
die("%s: cannot lock the ref", ref);
|
||||
if (write_ref_sha1(lock, repl, NULL) < 0)
|
||||
die("%s: cannot update the ref", ref);
|
||||
transaction = ref_transaction_begin(&err);
|
||||
if (!transaction ||
|
||||
ref_transaction_update(transaction, ref, repl, prev, 0, 1, &err) ||
|
||||
ref_transaction_commit(transaction, NULL, &err))
|
||||
die("%s", err.buf);
|
||||
|
||||
ref_transaction_free(transaction);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user