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:
26
sequencer.c
26
sequencer.c
@ -237,23 +237,33 @@ static int error_dirty_index(struct replay_opts *opts)
|
||||
static int fast_forward_to(const unsigned char *to, const unsigned char *from,
|
||||
int unborn, struct replay_opts *opts)
|
||||
{
|
||||
struct ref_lock *ref_lock;
|
||||
struct ref_transaction *transaction;
|
||||
struct strbuf sb = STRBUF_INIT;
|
||||
int ret;
|
||||
struct strbuf err = STRBUF_INIT;
|
||||
|
||||
read_cache();
|
||||
if (checkout_fast_forward(from, to, 1))
|
||||
exit(128); /* the callee should have complained already */
|
||||
ref_lock = lock_any_ref_for_update("HEAD", unborn ? null_sha1 : from,
|
||||
0, NULL);
|
||||
if (!ref_lock)
|
||||
return error(_("Failed to lock HEAD during fast_forward_to"));
|
||||
|
||||
strbuf_addf(&sb, "%s: fast-forward", action_name(opts));
|
||||
ret = write_ref_sha1(ref_lock, to, sb.buf);
|
||||
|
||||
transaction = ref_transaction_begin(&err);
|
||||
if (!transaction ||
|
||||
ref_transaction_update(transaction, "HEAD",
|
||||
to, unborn ? null_sha1 : from,
|
||||
0, 1, &err) ||
|
||||
ref_transaction_commit(transaction, sb.buf, &err)) {
|
||||
ref_transaction_free(transaction);
|
||||
error("%s", err.buf);
|
||||
strbuf_release(&sb);
|
||||
strbuf_release(&err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
strbuf_release(&sb);
|
||||
return ret;
|
||||
strbuf_release(&err);
|
||||
ref_transaction_free(transaction);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_recursive_merge(struct commit *base, struct commit *next,
|
||||
|
||||
Reference in New Issue
Block a user