From 23a3f0cb16caa1cc79cf0af42a92bff61fe955a4 Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Wed, 11 Apr 2018 17:21:09 -0700 Subject: refs: add repository argument to get_main_ref_store Add a repository argument to allow the get_main_ref_store caller to be more specific about which repository to handle. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet. As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time. Signed-off-by: Jonathan Nieder Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- refs.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'refs.h') diff --git a/refs.h b/refs.h index 01be5ae32f..0d013377ce 100644 --- a/refs.h +++ b/refs.h @@ -758,7 +758,9 @@ int reflog_expire(const char *refname, const struct object_id *oid, int ref_storage_backend_exists(const char *name); -struct ref_store *get_main_ref_store(void); +#define get_main_ref_store(r) \ + get_main_ref_store_##r() +struct ref_store *get_main_ref_store_the_repository(void); /* * Return the ref_store instance for the specified submodule. For the * main repository, use submodule==NULL; such a call cannot fail. For -- cgit v1.2.3 From 60ce76d35819a9679104b6615aa0466ae49023a0 Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Wed, 11 Apr 2018 17:21:10 -0700 Subject: refs: add repository argument to for_each_replace_ref Add a repository argument to allow for_each_replace_ref callers to be more specific about which repository to handle. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet. As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time. Signed-off-by: Jonathan Nieder Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- refs.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'refs.h') diff --git a/refs.h b/refs.h index 0d013377ce..ab3d2bec2f 100644 --- a/refs.h +++ b/refs.h @@ -300,7 +300,9 @@ int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data, int for_each_tag_ref(each_ref_fn fn, void *cb_data); int for_each_branch_ref(each_ref_fn fn, void *cb_data); int for_each_remote_ref(each_ref_fn fn, void *cb_data); -int for_each_replace_ref(each_ref_fn fn, void *cb_data); +#define for_each_replace_ref(r, fn, cb) \ + for_each_replace_ref_##r(fn, cb) +int for_each_replace_ref_the_repository(each_ref_fn fn, void *cb_data); int for_each_glob_ref(each_ref_fn fn, const char *pattern, void *cb_data); int for_each_glob_ref_in(each_ref_fn fn, const char *pattern, const char *prefix, void *cb_data); -- cgit v1.2.3 From 64a741619d27ede27788d2d444257635f4af8ffd Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Wed, 11 Apr 2018 17:21:14 -0700 Subject: refs: store the main ref store inside the repository struct This moves the 'main_ref_store', which was a global variable in refs.c into the repository struct. This patch does not deal with the parts in the refs subsystem which deal with the submodules there. A later patch needs to get rid of the submodule exposure in the refs API, such as 'get_submodule_ref_store(path)'. Acked-by: Michael Haggerty Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- refs.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'refs.h') diff --git a/refs.h b/refs.h index ab3d2bec2f..f5ab68c0ed 100644 --- a/refs.h +++ b/refs.h @@ -760,9 +760,7 @@ int reflog_expire(const char *refname, const struct object_id *oid, int ref_storage_backend_exists(const char *name); -#define get_main_ref_store(r) \ - get_main_ref_store_##r() -struct ref_store *get_main_ref_store_the_repository(void); +struct ref_store *get_main_ref_store(struct repository *r); /* * Return the ref_store instance for the specified submodule. For the * main repository, use submodule==NULL; such a call cannot fail. For -- cgit v1.2.3 From 0d296c57aec3a2c311abc5ebe7d1499bc41bc9df Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Wed, 11 Apr 2018 17:21:15 -0700 Subject: refs: allow for_each_replace_ref to handle arbitrary repositories Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- refs.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'refs.h') diff --git a/refs.h b/refs.h index f5ab68c0ed..15f3a91cc4 100644 --- a/refs.h +++ b/refs.h @@ -300,9 +300,7 @@ int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data, int for_each_tag_ref(each_ref_fn fn, void *cb_data); int for_each_branch_ref(each_ref_fn fn, void *cb_data); int for_each_remote_ref(each_ref_fn fn, void *cb_data); -#define for_each_replace_ref(r, fn, cb) \ - for_each_replace_ref_##r(fn, cb) -int for_each_replace_ref_the_repository(each_ref_fn fn, void *cb_data); +int for_each_replace_ref(struct repository *r, each_ref_fn fn, void *cb_data); int for_each_glob_ref(each_ref_fn fn, const char *pattern, void *cb_data); int for_each_glob_ref_in(each_ref_fn fn, const char *pattern, const char *prefix, void *cb_data); -- cgit v1.2.3