1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-28 19:46:14 +02:00

sequencer.c: use ref transactions for all ref updates

Change to use ref transactions for all updates to refs.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ronnie Sahlberg 2014-04-16 15:37:45 -07:00 committed by Junio C Hamano
parent c0fe1ed084
commit d668d16ca7

View File

@ -272,23 +272,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(1); /* 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,