diff options
author | Ronnie Sahlberg <sahlberg@google.com> | 2014-04-16 15:37:45 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-09-03 10:04:12 -0700 |
commit | d668d16ca7f6c31ee60cb4cc061dd1b62ea658de (patch) | |
tree | 03f5e6340fe879f53176231c6fcf396aa81c41f9 | |
parent | commit.c: use ref transactions for updates (diff) | |
download | tgif-d668d16ca7f6c31ee60cb4cc061dd1b62ea658de.tar.xz |
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>
-rw-r--r-- | sequencer.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/sequencer.c b/sequencer.c index 0a80c58d11..5e93b6ab5f 100644 --- a/sequencer.c +++ b/sequencer.c @@ -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, |