Skip to content

Commit a1e2581

Browse files
pks-tgitster
authored andcommitted
object-store: rename object_directory to odb_source
The `object_directory` structure is used as an access point for a single object directory like ".git/objects". While the structure isn't yet fully self-contained, the intent is for it to eventually contain all information required to access objects in one specific location. While the name "object directory" is a good fit for now, this will change over time as we continue with the agenda to make pluggable object databases a thing. Eventually, objects may not be accessed via any kind of directory at all anymore, but they could instead be backed by any kind of durable storage mechanism. While it seems quite far-fetched for now, it is thinkable that eventually this might even be some form of a database, for example. As such, the current name of this structure will become worse over time as we evolve into the direction of pluggable ODBs. Immediate next steps will start to carve out proper self-contained object directories, which requires us to pass in these object directories as parameters. Based on our modern naming schema this means that those functions should then be named after their subsystem, which means that we would start to bake the current name into the codebase more and more. Let's preempt this by renaming the structure. There have been a couple alternatives that were discussed: - `odb_backend` was discarded because it led to the association that one object database has a single backend, but the model is that one alternate has one backend. Furthermore, "backend" is more about the actual backing implementation and less about the high-level concept. - `odb_alternate` was discarded because it is a bit of a stretch to also call the main object directory an "alternate". Instead, pick `odb_source` as the new name. It makes it sufficiently clear that there can be multiple sources and does not cause confusion when mixed with the already-existing "alternate" terminology. In the future, this change allows us to easily introduce for example a `odb_files_source` and other format-specific implementations. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1ace066 commit a1e2581

28 files changed

+284
-272
lines changed

builtin/commit-graph.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix,
6666
struct repository *repo UNUSED)
6767
{
6868
struct commit_graph *graph = NULL;
69-
struct object_directory *odb = NULL;
69+
struct odb_source *source = NULL;
7070
char *graph_name;
7171
char *chain_name;
7272
enum { OPENED_NONE, OPENED_GRAPH, OPENED_CHAIN } opened = OPENED_NONE;
@@ -101,9 +101,9 @@ static int graph_verify(int argc, const char **argv, const char *prefix,
101101
if (opts.progress)
102102
flags |= COMMIT_GRAPH_WRITE_PROGRESS;
103103

104-
odb = find_odb(the_repository, opts.obj_dir);
105-
graph_name = get_commit_graph_filename(odb);
106-
chain_name = get_commit_graph_chain_filename(odb);
104+
source = find_odb(the_repository, opts.obj_dir);
105+
graph_name = get_commit_graph_filename(source);
106+
chain_name = get_commit_graph_chain_filename(source);
107107
if (open_commit_graph(graph_name, &fd, &st))
108108
opened = OPENED_GRAPH;
109109
else if (errno != ENOENT)
@@ -120,7 +120,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix,
120120
if (opened == OPENED_NONE)
121121
return 0;
122122
else if (opened == OPENED_GRAPH)
123-
graph = load_commit_graph_one_fd_st(the_repository, fd, &st, odb);
123+
graph = load_commit_graph_one_fd_st(the_repository, fd, &st, source);
124124
else
125125
graph = load_commit_graph_chain_fd_st(the_repository, fd, &st,
126126
&incomplete_chain);
@@ -221,7 +221,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,
221221
struct string_list pack_indexes = STRING_LIST_INIT_DUP;
222222
struct strbuf buf = STRBUF_INIT;
223223
struct oidset commits = OIDSET_INIT;
224-
struct object_directory *odb = NULL;
224+
struct odb_source *source = NULL;
225225
int result = 0;
226226
enum commit_graph_write_flags flags = 0;
227227
struct progress *progress = NULL;
@@ -289,10 +289,10 @@ static int graph_write(int argc, const char **argv, const char *prefix,
289289
git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))
290290
flags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;
291291

292-
odb = find_odb(the_repository, opts.obj_dir);
292+
source = find_odb(the_repository, opts.obj_dir);
293293

294294
if (opts.reachable) {
295-
if (write_commit_graph_reachable(odb, flags, &write_opts))
295+
if (write_commit_graph_reachable(source, flags, &write_opts))
296296
result = 1;
297297
goto cleanup;
298298
}
@@ -318,7 +318,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,
318318
stop_progress(&progress);
319319
}
320320

321-
if (write_commit_graph(odb,
321+
if (write_commit_graph(source,
322322
opts.stdin_packs ? &pack_indexes : NULL,
323323
opts.stdin_commits ? &commits : NULL,
324324
flags,

builtin/count-objects.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ static int count_cruft(const char *basename UNUSED, const char *path,
8080
return 0;
8181
}
8282

83-
static int print_alternate(struct object_directory *odb, void *data UNUSED)
83+
static int print_alternate(struct odb_source *alternate, void *data UNUSED)
8484
{
8585
printf("alternate: ");
86-
quote_c_style(odb->path, NULL, stdout, 0);
86+
quote_c_style(alternate->path, NULL, stdout, 0);
8787
putchar('\n');
8888
return 0;
8989
}

builtin/fetch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2653,7 +2653,7 @@ int cmd_fetch(int argc,
26532653
commit_graph_flags |= COMMIT_GRAPH_WRITE_PROGRESS;
26542654

26552655
trace2_region_enter("fetch", "write-commit-graph", the_repository);
2656-
write_commit_graph_reachable(the_repository->objects->odb,
2656+
write_commit_graph_reachable(the_repository->objects->sources,
26572657
commit_graph_flags,
26582658
NULL);
26592659
trace2_region_leave("fetch", "write-commit-graph", the_repository);

builtin/fsck.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ int cmd_fsck(int argc,
956956
struct repository *repo UNUSED)
957957
{
958958
int i;
959-
struct object_directory *odb;
959+
struct odb_source *source;
960960

961961
/* fsck knows how to handle missing promisor objects */
962962
fetch_if_missing = 0;
@@ -998,8 +998,8 @@ int cmd_fsck(int argc,
998998
mark_packed_for_connectivity, NULL, 0);
999999
} else {
10001000
prepare_alt_odb(the_repository);
1001-
for (odb = the_repository->objects->odb; odb; odb = odb->next)
1002-
fsck_object_dir(odb->path);
1001+
for (source = the_repository->objects->sources; source; source = source->next)
1002+
fsck_object_dir(source->path);
10031003

10041004
if (check_full) {
10051005
struct packed_git *p;
@@ -1109,11 +1109,11 @@ int cmd_fsck(int argc,
11091109
struct child_process commit_graph_verify = CHILD_PROCESS_INIT;
11101110

11111111
prepare_alt_odb(the_repository);
1112-
for (odb = the_repository->objects->odb; odb; odb = odb->next) {
1112+
for (source = the_repository->objects->sources; source; source = source->next) {
11131113
child_process_init(&commit_graph_verify);
11141114
commit_graph_verify.git_cmd = 1;
11151115
strvec_pushl(&commit_graph_verify.args, "commit-graph",
1116-
"verify", "--object-dir", odb->path, NULL);
1116+
"verify", "--object-dir", source->path, NULL);
11171117
if (show_progress)
11181118
strvec_push(&commit_graph_verify.args, "--progress");
11191119
else
@@ -1127,11 +1127,11 @@ int cmd_fsck(int argc,
11271127
struct child_process midx_verify = CHILD_PROCESS_INIT;
11281128

11291129
prepare_alt_odb(the_repository);
1130-
for (odb = the_repository->objects->odb; odb; odb = odb->next) {
1130+
for (source = the_repository->objects->sources; source; source = source->next) {
11311131
child_process_init(&midx_verify);
11321132
midx_verify.git_cmd = 1;
11331133
strvec_pushl(&midx_verify.args, "multi-pack-index",
1134-
"verify", "--object-dir", odb->path, NULL);
1134+
"verify", "--object-dir", source->path, NULL);
11351135
if (show_progress)
11361136
strvec_push(&midx_verify.args, "--progress");
11371137
else

builtin/gc.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ int cmd_gc(int argc,
10181018
}
10191019

10201020
if (the_repository->settings.gc_write_commit_graph == 1)
1021-
write_commit_graph_reachable(the_repository->objects->odb,
1021+
write_commit_graph_reachable(the_repository->objects->sources,
10221022
!quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0,
10231023
NULL);
10241024

@@ -1271,7 +1271,7 @@ static int loose_object_auto_condition(struct gc_config *cfg UNUSED)
12711271
if (loose_object_auto_limit < 0)
12721272
return 1;
12731273

1274-
return for_each_loose_file_in_objdir(the_repository->objects->odb->path,
1274+
return for_each_loose_file_in_objdir(the_repository->objects->sources->path,
12751275
loose_object_count,
12761276
NULL, NULL, &count);
12771277
}
@@ -1306,7 +1306,7 @@ static int pack_loose(struct maintenance_run_opts *opts)
13061306
* Do not start pack-objects process
13071307
* if there are no loose objects.
13081308
*/
1309-
if (!for_each_loose_file_in_objdir(r->objects->odb->path,
1309+
if (!for_each_loose_file_in_objdir(r->objects->sources->path,
13101310
bail_on_loose,
13111311
NULL, NULL, NULL))
13121312
return 0;
@@ -1318,7 +1318,7 @@ static int pack_loose(struct maintenance_run_opts *opts)
13181318
strvec_push(&pack_proc.args, "--quiet");
13191319
else
13201320
strvec_push(&pack_proc.args, "--no-quiet");
1321-
strvec_pushf(&pack_proc.args, "%s/pack/loose", r->objects->odb->path);
1321+
strvec_pushf(&pack_proc.args, "%s/pack/loose", r->objects->sources->path);
13221322

13231323
pack_proc.in = -1;
13241324

@@ -1346,7 +1346,7 @@ static int pack_loose(struct maintenance_run_opts *opts)
13461346
else if (data.batch_size > 0)
13471347
data.batch_size--; /* Decrease for equality on limit. */
13481348

1349-
for_each_loose_file_in_objdir(r->objects->odb->path,
1349+
for_each_loose_file_in_objdir(r->objects->sources->path,
13501350
write_loose_object_to_stdin,
13511351
NULL,
13521352
NULL,
@@ -1611,7 +1611,7 @@ static int maintenance_run_tasks(struct maintenance_run_opts *opts,
16111611
int result = 0;
16121612
struct lock_file lk;
16131613
struct repository *r = the_repository;
1614-
char *lock_path = xstrfmt("%s/maintenance", r->objects->odb->path);
1614+
char *lock_path = xstrfmt("%s/maintenance", r->objects->sources->path);
16151615

16161616
if (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) {
16171617
/*
@@ -3083,7 +3083,7 @@ static int update_background_schedule(const struct maintenance_start_opts *opts,
30833083
unsigned int i;
30843084
int result = 0;
30853085
struct lock_file lk;
3086-
char *lock_path = xstrfmt("%s/schedule", the_repository->objects->odb->path);
3086+
char *lock_path = xstrfmt("%s/schedule", the_repository->objects->sources->path);
30873087

30883088
if (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) {
30893089
if (errno == EEXIST)

builtin/grep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ static int grep_submodule(struct grep_opt *opt,
505505
* lazily registered as alternates when needed (and except in an
506506
* unexpected code interaction, it won't be needed).
507507
*/
508-
add_submodule_odb_by_path(subrepo->objects->odb->path);
508+
add_submodule_odb_by_path(subrepo->objects->sources->path);
509509
obj_read_unlock();
510510

511511
memcpy(&subopt, opt, sizeof(subopt));

builtin/multi-pack-index.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ int cmd_multi_pack_index(int argc,
294294

295295
if (the_repository &&
296296
the_repository->objects &&
297-
the_repository->objects->odb)
298-
opts.object_dir = xstrdup(the_repository->objects->odb->path);
297+
the_repository->objects->sources)
298+
opts.object_dir = xstrdup(the_repository->objects->sources->path);
299299

300300
argc = parse_options(argc, argv, prefix, options,
301301
builtin_multi_pack_index_usage, 0);

builtin/submodule--helper.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,7 @@ static const char alternate_error_advice[] = N_(
15821582
);
15831583

15841584
static int add_possible_reference_from_superproject(
1585-
struct object_directory *odb, void *sas_cb)
1585+
struct odb_source *alt_odb, void *sas_cb)
15861586
{
15871587
struct submodule_alternate_setup *sas = sas_cb;
15881588
size_t len;
@@ -1591,12 +1591,12 @@ static int add_possible_reference_from_superproject(
15911591
* If the alternate object store is another repository, try the
15921592
* standard layout with .git/(modules/<name>)+/objects
15931593
*/
1594-
if (strip_suffix(odb->path, "/objects", &len)) {
1594+
if (strip_suffix(alt_odb->path, "/objects", &len)) {
15951595
struct repository alternate;
15961596
char *sm_alternate;
15971597
struct strbuf sb = STRBUF_INIT;
15981598
struct strbuf err = STRBUF_INIT;
1599-
strbuf_add(&sb, odb->path, len);
1599+
strbuf_add(&sb, alt_odb->path, len);
16001600

16011601
if (repo_init(&alternate, sb.buf, NULL) < 0)
16021602
die(_("could not get a repository handle for gitdir '%s'"),

bundle.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ int verify_bundle(struct repository *r,
233233
.quiet = 1,
234234
};
235235

236-
if (!r || !r->objects || !r->objects->odb)
236+
if (!r || !r->objects || !r->objects->sources)
237237
return error(_("need a repository to verify a bundle"));
238238

239239
for (i = 0; i < p->nr; i++) {

0 commit comments

Comments
 (0)