Skip to content

Commit 64a7416

Browse files
stefanbellergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1f2e7ce commit 64a7416

File tree

4 files changed

+9
-15
lines changed

4 files changed

+9
-15
lines changed

refs.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,9 +1608,6 @@ static struct ref_store_hash_entry *alloc_ref_store_hash_entry(
16081608
return entry;
16091609
}
16101610

1611-
/* A pointer to the ref_store for the main repository: */
1612-
static struct ref_store *main_ref_store;
1613-
16141611
/* A hashmap of ref_stores, stored by submodule name: */
16151612
static struct hashmap submodule_ref_stores;
16161613

@@ -1652,13 +1649,13 @@ static struct ref_store *ref_store_init(const char *gitdir,
16521649
return refs;
16531650
}
16541651

1655-
struct ref_store *get_main_ref_store_the_repository(void)
1652+
struct ref_store *get_main_ref_store(struct repository *r)
16561653
{
1657-
if (main_ref_store)
1658-
return main_ref_store;
1654+
if (r->refs)
1655+
return r->refs;
16591656

1660-
main_ref_store = ref_store_init(get_git_dir(), REF_STORE_ALL_CAPS);
1661-
return main_ref_store;
1657+
r->refs = ref_store_init(r->gitdir, REF_STORE_ALL_CAPS);
1658+
return r->refs;
16621659
}
16631660

16641661
/*

refs.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -760,9 +760,7 @@ int reflog_expire(const char *refname, const struct object_id *oid,
760760

761761
int ref_storage_backend_exists(const char *name);
762762

763-
#define get_main_ref_store(r) \
764-
get_main_ref_store_##r()
765-
struct ref_store *get_main_ref_store_the_repository(void);
763+
struct ref_store *get_main_ref_store(struct repository *r);
766764
/*
767765
* Return the ref_store instance for the specified submodule. For the
768766
* main repository, use submodule==NULL; such a call cannot fail. For

refs/files-backend.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ struct ref_lock {
6161
struct object_id old_oid;
6262
};
6363

64-
/*
65-
* Future: need to be in "struct repository"
66-
* when doing a full libification.
67-
*/
6864
struct files_ref_store {
6965
struct ref_store base;
7066
unsigned int store_flags;

repository.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ struct repository {
2626
*/
2727
struct raw_object_store *objects;
2828

29+
/* The store in which the refs are held. */
30+
struct ref_store *refs;
31+
2932
/*
3033
* Path to the repository's graft file.
3134
* Cannot be NULL after initialization.

0 commit comments

Comments
 (0)