diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2017-03-26 09:42:29 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-03-27 10:23:39 -0700 |
commit | 077be78d7ff0d44cab311da315b2f8dbd2a0d57b (patch) | |
tree | 1be9188fd97c11e6de6bf0de2a62ca49c62972b0 | |
parent | 378dc9103a6b36ecac5f63eb0d5a87f573081094 (diff) | |
download | git-077be78d7ff0d44cab311da315b2f8dbd2a0d57b.tar.gz |
refs.c: make get_main_ref_store() public and use it
get_ref_store() will soon be renamed to get_submodule_ref_store().
Together with future get_worktree_ref_store(), the three functions
provide an appropriate ref store for different operation modes. New APIs
will be added to operate directly on ref stores.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | refs.c | 36 | ||||
-rw-r--r-- | refs.h | 3 | ||||
-rw-r--r-- | refs/files-backend.c | 2 |
3 files changed, 22 insertions, 19 deletions
@@ -1314,7 +1314,7 @@ const char *resolve_ref_recursively(struct ref_store *refs, /* backend functions */ int refs_init_db(struct strbuf *err) { - struct ref_store *refs = get_ref_store(NULL); + struct ref_store *refs = get_main_ref_store(); return refs->be->init_db(refs, err); } @@ -1322,7 +1322,7 @@ int refs_init_db(struct strbuf *err) const char *resolve_ref_unsafe(const char *refname, int resolve_flags, unsigned char *sha1, int *flags) { - return resolve_ref_recursively(get_ref_store(NULL), refname, + return resolve_ref_recursively(get_main_ref_store(), refname, resolve_flags, sha1, flags); } @@ -1428,7 +1428,7 @@ static struct ref_store *ref_store_init(const char *submodule) return refs; } -static struct ref_store *get_main_ref_store(void) +struct ref_store *get_main_ref_store(void) { if (main_ref_store) return main_ref_store; @@ -1488,14 +1488,14 @@ void base_ref_store_init(struct ref_store *refs, /* backend functions */ int pack_refs(unsigned int flags) { - struct ref_store *refs = get_ref_store(NULL); + struct ref_store *refs = get_main_ref_store(); return refs->be->pack_refs(refs, flags); } int peel_ref(const char *refname, unsigned char *sha1) { - struct ref_store *refs = get_ref_store(NULL); + struct ref_store *refs = get_main_ref_store(); return refs->be->peel_ref(refs, refname, sha1); } @@ -1503,7 +1503,7 @@ int peel_ref(const char *refname, unsigned char *sha1) int create_symref(const char *ref_target, const char *refs_heads_master, const char *logmsg) { - struct ref_store *refs = get_ref_store(NULL); + struct ref_store *refs = get_main_ref_store(); return refs->be->create_symref(refs, ref_target, refs_heads_master, logmsg); @@ -1512,7 +1512,7 @@ int create_symref(const char *ref_target, const char *refs_heads_master, int ref_transaction_commit(struct ref_transaction *transaction, struct strbuf *err) { - struct ref_store *refs = get_ref_store(NULL); + struct ref_store *refs = get_main_ref_store(); return refs->be->transaction_commit(refs, transaction, err); } @@ -1522,14 +1522,14 @@ int verify_refname_available(const char *refname, const struct string_list *skip, struct strbuf *err) { - struct ref_store *refs = get_ref_store(NULL); + struct ref_store *refs = get_main_ref_store(); return refs->be->verify_refname_available(refs, refname, extra, skip, err); } int for_each_reflog(each_ref_fn fn, void *cb_data) { - struct ref_store *refs = get_ref_store(NULL); + struct ref_store *refs = get_main_ref_store(); struct ref_iterator *iter; iter = refs->be->reflog_iterator_begin(refs); @@ -1540,7 +1540,7 @@ int for_each_reflog(each_ref_fn fn, void *cb_data) int for_each_reflog_ent_reverse(const char *refname, each_reflog_ent_fn fn, void *cb_data) { - struct ref_store *refs = get_ref_store(NULL); + struct ref_store *refs = get_main_ref_store(); return refs->be->for_each_reflog_ent_reverse(refs, refname, fn, cb_data); @@ -1549,14 +1549,14 @@ int for_each_reflog_ent_reverse(const char *refname, each_reflog_ent_fn fn, int for_each_reflog_ent(const char *refname, each_reflog_ent_fn fn, void *cb_data) { - struct ref_store *refs = get_ref_store(NULL); + struct ref_store *refs = get_main_ref_store(); return refs->be->for_each_reflog_ent(refs, refname, fn, cb_data); } int reflog_exists(const char *refname) { - struct ref_store *refs = get_ref_store(NULL); + struct ref_store *refs = get_main_ref_store(); return refs->be->reflog_exists(refs, refname); } @@ -1564,14 +1564,14 @@ int reflog_exists(const char *refname) int safe_create_reflog(const char *refname, int force_create, struct strbuf *err) { - struct ref_store *refs = get_ref_store(NULL); + struct ref_store *refs = get_main_ref_store(); return refs->be->create_reflog(refs, refname, force_create, err); } int delete_reflog(const char *refname) { - struct ref_store *refs = get_ref_store(NULL); + struct ref_store *refs = get_main_ref_store(); return refs->be->delete_reflog(refs, refname); } @@ -1583,7 +1583,7 @@ int reflog_expire(const char *refname, const unsigned char *sha1, reflog_expiry_cleanup_fn cleanup_fn, void *policy_cb_data) { - struct ref_store *refs = get_ref_store(NULL); + struct ref_store *refs = get_main_ref_store(); return refs->be->reflog_expire(refs, refname, sha1, flags, prepare_fn, should_prune_fn, @@ -1593,21 +1593,21 @@ int reflog_expire(const char *refname, const unsigned char *sha1, int initial_ref_transaction_commit(struct ref_transaction *transaction, struct strbuf *err) { - struct ref_store *refs = get_ref_store(NULL); + struct ref_store *refs = get_main_ref_store(); return refs->be->initial_transaction_commit(refs, transaction, err); } int delete_refs(struct string_list *refnames, unsigned int flags) { - struct ref_store *refs = get_ref_store(NULL); + struct ref_store *refs = get_main_ref_store(); return refs->be->delete_refs(refs, refnames, flags); } int rename_ref(const char *oldref, const char *newref, const char *logmsg) { - struct ref_store *refs = get_ref_store(NULL); + struct ref_store *refs = get_main_ref_store(); return refs->be->rename_ref(refs, oldref, newref, logmsg); } @@ -2,6 +2,7 @@ #define REFS_H struct object_id; +struct ref_store; struct strbuf; struct string_list; @@ -560,4 +561,6 @@ int reflog_expire(const char *refname, const unsigned char *sha1, int ref_storage_backend_exists(const char *name); +struct ref_store *get_main_ref_store(void); + #endif /* REFS_H */ diff --git a/refs/files-backend.c b/refs/files-backend.c index 9676cd32e4..b62f374f9c 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -3163,7 +3163,7 @@ int set_worktree_head_symref(const char *gitdir, const char *target, const char * backends. This function needs to die. */ struct files_ref_store *refs = - files_downcast(get_ref_store(NULL), 0, "set_head_symref"); + files_downcast(get_main_ref_store(), 0, "set_head_symref"); static struct lock_file head_lock; struct ref_lock *lock; |