Skip to content

Commit 1ace066

Browse files
pks-tgitster
authored andcommitted
object-store: rename raw_object_store to object_database
The `raw_object_store` structure is the central entry point for reading and writing objects in a repository. The main purpose of this structure is to manage object directories and provide an interface to access and write objects in those object directories. Right now, many of the functions associated with the raw object store implicitly rely on `the_repository` to get access to its `objects` pointer, which is the `raw_object_store`. As we want to generally get rid of using `the_repository` across our codebase we will have to convert this implicit dependency on this global variable into an explicit parameter. This conversion can be done by simply passing in an explicit pointer to a repository and then using its `->objects` pointer. But there is a second effort underway, which is to make the object subsystem more selfcontained so that we can eventually have pluggable object backends. As such, passing in a repository wouldn't make a ton of sense, and the goal is to convert the object store interfaces such that we always pass in a reference to the `raw_object_store` instead. This will expose the `raw_object_store` type to a lot more callers though, which surfaces that this type is named somewhat awkwardly. The "raw_" prefix makes readers wonder whether there is a non-raw variant of the object store, but there isn't. Furthermore, we nowadays want to name functions in a way that they can be clearly attributed to a specific subsystem, but calling them e.g. `raw_object_store_has_object()` is just too unwieldy, even when dropping the "raw_" prefix. Instead, rename the structure to `object_database`. This term is already used a lot throughout our codebase, and it cannot easily be mistaken for "object directories", either. Furthermore, its acronym ODB is already well-known and works well as part of a function's name, like for example `odb_has_object()`. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7014b55 commit 1ace066

File tree

8 files changed

+24
-19
lines changed

8 files changed

+24
-19
lines changed

commit-graph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ struct bloom_filter_settings *get_bloom_filter_settings(struct repository *r)
829829
return NULL;
830830
}
831831

832-
void close_commit_graph(struct raw_object_store *o)
832+
void close_commit_graph(struct object_database *o)
833833
{
834834
if (!o->commit_graph)
835835
return;

commit-graph.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void git_test_write_commit_graph_or_die(void);
2626
struct commit;
2727
struct bloom_filter_settings;
2828
struct repository;
29-
struct raw_object_store;
29+
struct object_database;
3030
struct string_list;
3131

3232
char *get_commit_graph_filename(struct object_directory *odb);
@@ -186,7 +186,7 @@ int write_commit_graph(struct object_directory *odb,
186186

187187
int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags);
188188

189-
void close_commit_graph(struct raw_object_store *);
189+
void close_commit_graph(struct object_database *);
190190
void free_commit_graph(struct commit_graph *);
191191

192192
/*

object-store.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct cached_object_entry {
4444
} value;
4545
};
4646

47-
static const struct cached_object *find_cached_object(struct raw_object_store *object_store,
47+
static const struct cached_object *find_cached_object(struct object_database *object_store,
4848
const struct object_id *oid)
4949
{
5050
static const struct cached_object empty_tree = {
@@ -86,7 +86,7 @@ int odb_mkstemp(struct strbuf *temp_filename, const char *pattern)
8686
/*
8787
* Return non-zero iff the path is usable as an alternate object database.
8888
*/
89-
static int alt_odb_usable(struct raw_object_store *o,
89+
static int alt_odb_usable(struct object_database *o,
9090
struct strbuf *path,
9191
const char *normalized_objdir, khiter_t *pos)
9292
{
@@ -950,9 +950,9 @@ void assert_oid_type(const struct object_id *oid, enum object_type expect)
950950
type_name(expect));
951951
}
952952

953-
struct raw_object_store *raw_object_store_new(void)
953+
struct object_database *odb_new(void)
954954
{
955-
struct raw_object_store *o = xmalloc(sizeof(*o));
955+
struct object_database *o = xmalloc(sizeof(*o));
956956

957957
memset(o, 0, sizeof(*o));
958958
INIT_LIST_HEAD(&o->packed_git_mru);
@@ -961,7 +961,7 @@ struct raw_object_store *raw_object_store_new(void)
961961
return o;
962962
}
963963

964-
static void free_object_directories(struct raw_object_store *o)
964+
static void free_object_directories(struct object_database *o)
965965
{
966966
while (o->odb) {
967967
struct object_directory *next;
@@ -974,7 +974,7 @@ static void free_object_directories(struct raw_object_store *o)
974974
o->odb_by_path = NULL;
975975
}
976976

977-
void raw_object_store_clear(struct raw_object_store *o)
977+
void odb_clear(struct object_database *o)
978978
{
979979
FREE_AND_NULL(o->alternate_db);
980980

object-store.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@ struct packed_git;
8787
struct multi_pack_index;
8888
struct cached_object_entry;
8989

90-
struct raw_object_store {
90+
/*
91+
* The object database encapsulates access to objects in a repository. It
92+
* manages one or more backends that store the actual objects which are
93+
* configured via alternates.
94+
*/
95+
struct object_database {
9196
/*
9297
* Set of all object directories; the main directory is first (and
9398
* cannot be NULL after initialization). Subsequent directories are
@@ -169,8 +174,8 @@ struct raw_object_store {
169174
unsigned packed_git_initialized : 1;
170175
};
171176

172-
struct raw_object_store *raw_object_store_new(void);
173-
void raw_object_store_clear(struct raw_object_store *o);
177+
struct object_database *odb_new(void);
178+
void odb_clear(struct object_database *o);
174179

175180
/*
176181
* Create a temporary file rooted in the object database directory, or

packfile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ void close_pack(struct packed_git *p)
359359
oidset_clear(&p->bad_objects);
360360
}
361361

362-
void close_object_store(struct raw_object_store *o)
362+
void close_object_store(struct object_database *o)
363363
{
364364
struct packed_git *p;
365365

packfile.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,12 @@ int close_pack_fd(struct packed_git *p);
183183

184184
uint32_t get_pack_fanout(struct packed_git *p, uint32_t value);
185185

186-
struct raw_object_store;
186+
struct object_database;
187187

188188
unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *);
189189
void close_pack_windows(struct packed_git *);
190190
void close_pack(struct packed_git *);
191-
void close_object_store(struct raw_object_store *o);
191+
void close_object_store(struct object_database *o);
192192
void unuse_pack(struct pack_window **);
193193
void clear_delta_base_cache(void);
194194
struct packed_git *add_packed_git(struct repository *r, const char *path,

repository.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static void set_default_hash_algo(struct repository *repo)
5252

5353
void initialize_repository(struct repository *repo)
5454
{
55-
repo->objects = raw_object_store_new();
55+
repo->objects = odb_new();
5656
repo->remote_state = remote_state_new();
5757
repo->parsed_objects = parsed_object_pool_new(repo);
5858
ALLOC_ARRAY(repo->index, 1);
@@ -374,7 +374,7 @@ void repo_clear(struct repository *repo)
374374
FREE_AND_NULL(repo->worktree);
375375
FREE_AND_NULL(repo->submodule_prefix);
376376

377-
raw_object_store_clear(repo->objects);
377+
odb_clear(repo->objects);
378378
FREE_AND_NULL(repo->objects);
379379

380380
parsed_object_pool_clear(repo->parsed_objects);

repository.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ struct git_hash_algo;
99
struct index_state;
1010
struct lock_file;
1111
struct pathspec;
12-
struct raw_object_store;
12+
struct object_database;
1313
struct submodule_cache;
1414
struct promisor_remote_config;
1515
struct remote_state;
@@ -47,7 +47,7 @@ struct repository {
4747
/*
4848
* Holds any information related to accessing the raw object content.
4949
*/
50-
struct raw_object_store *objects;
50+
struct object_database *objects;
5151

5252
/*
5353
* All objects in this repository that have been parsed. This structure

0 commit comments

Comments
 (0)