Merge branch 'mh/ref-store'
authorJunio C Hamano <gitster@pobox.com>
Mon, 19 Sep 2016 20:47:19 +0000 (13:47 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 19 Sep 2016 20:47:19 +0000 (13:47 -0700)
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
...

1  2 
builtin/init-db.c
refs.c
refs.h
refs/files-backend.c
Simple merge
diff --cc refs.c
Simple merge
diff --cc refs.h
Simple merge
index 1f34b444af8dd5fbbacc67f0a13510005225c6cc,47710fcf286283871c0949e888e4b319a7e83616..0709f60b8e8c43fa830c0e678fdf7b83435535bb
@@@ -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) &&
                         * 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;