From: Junio C Hamano Date: Mon, 19 Sep 2016 20:47:19 +0000 (-0700) Subject: Merge branch 'mh/ref-store' X-Git-Tag: v2.11.0-rc0~143 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4322f3848a224843a2df81055f07899ce1a1b388;p=thirdparty%2Fgit.git Merge branch 'mh/ref-store' The ref-store abstraction was introduced to the refs API so that we can plug in different backends to store references. * mh/ref-store: (38 commits) refs: implement iteration over only per-worktree refs refs: make lock generic refs: add method to rename refs refs: add methods to init refs db refs: make delete_refs() virtual refs: add method for initial ref transaction commit refs: add methods for reflog refs: add method iterator_begin files_ref_iterator_begin(): take a ref_store argument split_symref_update(): add a files_ref_store argument lock_ref_sha1_basic(): add a files_ref_store argument lock_ref_for_update(): add a files_ref_store argument commit_ref_update(): add a files_ref_store argument lock_raw_ref(): add a files_ref_store argument repack_without_refs(): add a files_ref_store argument refs: make peel_ref() virtual refs: make create_symref() virtual refs: make pack_refs() virtual refs: make verify_refname_available() virtual refs: make read_raw_ref() virtual ... --- 4322f3848a224843a2df81055f07899ce1a1b388 diff --cc refs/files-backend.c index 1f34b444af,47710fcf28..0709f60b8e --- a/refs/files-backend.c +++ b/refs/files-backend.c @@@ -1225,10 -1201,9 +1201,10 @@@ static void read_loose_refs(const char struct strbuf refname; struct strbuf path = STRBUF_INIT; size_t path_baselen; + int err = 0; - if (*refs->name) - err = strbuf_git_path_submodule(&path, refs->name, "%s", dirname); + if (*refs->base.submodule) - strbuf_git_path_submodule(&path, refs->base.submodule, "%s", dirname); ++ err = strbuf_git_path_submodule(&path, refs->base.submodule, "%s", dirname); else strbuf_git_path(&path, "%s", dirname); path_baselen = path.len; @@@ -3652,8 -3592,23 +3622,9 @@@ static int lock_ref_for_update(struct f for (parent_update = update->parent_update; parent_update; parent_update = parent_update->parent_update) { - oidcpy(&parent_update->lock->old_oid, &lock->old_oid); + struct ref_lock *parent_lock = parent_update->backend_data; + oidcpy(&parent_lock->old_oid, &lock->old_oid); } - - if ((update->flags & REF_HAVE_OLD) && - hashcmp(lock->old_oid.hash, update->old_sha1)) { - if (is_null_sha1(update->old_sha1)) - strbuf_addf(err, "cannot lock ref '%s': reference already exists", - original_update_refname(update)); - else - strbuf_addf(err, "cannot lock ref '%s': is at %s but expected %s", - original_update_refname(update), - sha1_to_hex(lock->old_oid.hash), - sha1_to_hex(update->old_sha1)); - - return TRANSACTION_GENERIC_ERROR; - } } if ((update->flags & REF_HAVE_NEW) && @@@ -3673,9 -3628,9 +3644,9 @@@ * The lock was freed upon failure of * write_ref_to_lockfile(): */ - update->lock = NULL; + update->backend_data = NULL; strbuf_addf(err, - "cannot update the ref '%s': %s", + "cannot update ref '%s': %s", update->refname, write_err); free(write_err); return TRANSACTION_GENERIC_ERROR;