37
if (git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))
38
flags = COMMIT_GRAPH_WRITE_BLOOM_FILTERS;
39
40
- if (write_commit_graph_reachable(the_repository->objects->odb,
40
+ if (write_commit_graph_reachable(the_repository->objects->sources,
41
flags, NULL))
42
die("failed to write commit-graph under GIT_TEST_COMMIT_GRAPH");
43
}
191
return 0;
192
}
193
194
-char *get_commit_graph_filename(struct object_directory *obj_dir)
194
+char *get_commit_graph_filename(struct odb_source *source)
195
{
196
- return xstrfmt("%s/info/commit-graph", obj_dir->path);
196
+ return xstrfmt("%s/info/commit-graph", source->path);
197
}
198
199
-static char *get_split_graph_filename(struct object_directory *odb,
199
+static char *get_split_graph_filename(struct odb_source *source,
200
const char *oid_hex)
201
{
202
- return xstrfmt("%s/info/commit-graphs/graph-%s.graph", odb->path,
202
+ return xstrfmt("%s/info/commit-graphs/graph-%s.graph", source->path,
203
oid_hex);
204
}
205
206
-char *get_commit_graph_chain_filename(struct object_directory *odb)
206
+char *get_commit_graph_chain_filename(struct odb_source *source)
207
{
208
- return xstrfmt("%s/info/commit-graphs/commit-graph-chain", odb->path);
208
+ return xstrfmt("%s/info/commit-graphs/commit-graph-chain", source->path);
209
}
210
211
static struct commit_graph *alloc_commit_graph(void)
250
251
struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,
252
int fd, struct stat *st,
253
- struct object_directory *odb)
253
+ struct odb_source *source)
254
{
255
void *graph_map;
256
size_t graph_size;
269
ret = parse_commit_graph(&r->settings, graph_map, graph_size);
270
271
if (ret)
272
- ret->odb = odb;
272
+ ret->odb_source = source;
273
else
274
munmap(graph_map, graph_size);
275
487
488
static struct commit_graph *load_commit_graph_one(struct repository *r,
489
const char *graph_file,
490
- struct object_directory *odb)
490
+ struct odb_source *source)
491
{
492
493
struct stat st;
498
if (!open_ok)
499
return NULL;
500
501
- g = load_commit_graph_one_fd_st(r, fd, &st, odb);
501
+ g = load_commit_graph_one_fd_st(r, fd, &st, source);
502
503
if (g)
504
g->filename = xstrdup(graph_file);
507
}
508
509
static struct commit_graph *load_commit_graph_v1(struct repository *r,
510
- struct object_directory *odb)
510
+ struct odb_source *source)
511
{
512
- char *graph_name = get_commit_graph_filename(odb);
513
- struct commit_graph *g = load_commit_graph_one(r, graph_name, odb);
512
+ char *graph_name = get_commit_graph_filename(source);
513
+ struct commit_graph *g = load_commit_graph_one(r, graph_name, source);
514
free(graph_name);
515
516
return g;
652
prepare_alt_odb(r);
653
654
for (i = 0; i < count; i++) {
655
- struct object_directory *odb;
655
+ struct odb_source *source;
656
657
if (strbuf_getline_lf(&line, fp) == EOF)
658
break;
665
}
666
667
valid = 0;
668
- for (odb = r->objects->odb; odb; odb = odb->next) {
669
- char *graph_name = get_split_graph_filename(odb, line.buf);
670
- struct commit_graph *g = load_commit_graph_one(r, graph_name, odb);
668
+ for (source = r->objects->sources; source; source = source->next) {
669
+ char *graph_name = get_split_graph_filename(source, line.buf);
670
+ struct commit_graph *g = load_commit_graph_one(r, graph_name, source);
671
672
free(graph_name);
673
701
}
702
703
static struct commit_graph *load_commit_graph_chain(struct repository *r,
704
- struct object_directory *odb)
704
+ struct odb_source *source)
705
{
706
- char *chain_file = get_commit_graph_chain_filename(odb);
706
+ char *chain_file = get_commit_graph_chain_filename(source);
707
struct stat st;
708
int fd;
709
struct commit_graph *g = NULL;
719
}
720
721
struct commit_graph *read_commit_graph_one(struct repository *r,
722
- struct object_directory *odb)
722
+ struct odb_source *source)
723
{
724
- struct commit_graph *g = load_commit_graph_v1(r, odb);
724
+ struct commit_graph *g = load_commit_graph_v1(r, source);
725
726
if (!g)
727
- g = load_commit_graph_chain(r, odb);
727
+ g = load_commit_graph_chain(r, source);
728
729
return g;
730
}
731
732
static void prepare_commit_graph_one(struct repository *r,
733
- struct object_directory *odb)
733
+ struct odb_source *source)
734
{
735
736
if (r->objects->commit_graph)
737
return;
738
739
- r->objects->commit_graph = read_commit_graph_one(r, odb);
739
+ r->objects->commit_graph = read_commit_graph_one(r, source);
740
}
741
742
/*
747
*/
748
static int prepare_commit_graph(struct repository *r)
749
{
750
- struct object_directory *odb;
750
+ struct odb_source *source;
751
752
/*
753
* Early return if there is no git dir or if the commit graph is
779
return 0;
780
781
prepare_alt_odb(r);
782
- for (odb = r->objects->odb;
783
- !r->objects->commit_graph && odb;
784
- odb = odb->next)
785
- prepare_commit_graph_one(r, odb);
782
+ for (source = r->objects->sources;
783
+ !r->objects->commit_graph && source;
784
+ source = source->next)
785
+ prepare_commit_graph_one(r, source);
786
return !!r->objects->commit_graph;
787
}
788
1137
1138
struct write_commit_graph_context {
1139
struct repository *r;
1140
- struct object_directory *odb;
1140
+ struct odb_source *odb_source;
1141
char *graph_name;
1142
struct oid_array oids;
1143
struct packed_commit_list commits;
1870
return 0;
1871
}
1872
1873
-int write_commit_graph_reachable(struct object_directory *odb,
1873
+int write_commit_graph_reachable(struct odb_source *source,
1874
enum commit_graph_write_flags flags,
1875
const struct commit_graph_opts *opts)
1876
{
1890
1891
stop_progress(&data.progress);
1892
1893
- result = write_commit_graph(odb, NULL, &commits,
1893
+ result = write_commit_graph(source, NULL, &commits,
1894
flags, opts);
1895
1896
oidset_clear(&commits);
1906
int dirlen;
1907
int ret = 0;
1908
1909
- strbuf_addf(&packname, "%s/pack/", ctx->odb->path);
1909
+ strbuf_addf(&packname, "%s/pack/", ctx->odb_source->path);
1910
dirlen = packname.len;
1911
if (ctx->report_progress) {
1912
strbuf_addf(&progress_title,
2060
2061
strbuf_addf(&tmp_file,
2062
"%s/info/commit-graphs/tmp_graph_XXXXXX",
2063
- ctx->odb->path);
2063
+ ctx->odb_source->path);
2064
ctx->graph_name = strbuf_detach(&tmp_file, NULL);
2065
} else {
2066
- ctx->graph_name = get_commit_graph_filename(ctx->odb);
2066
+ ctx->graph_name = get_commit_graph_filename(ctx->odb_source);
2067
}
2068
2069
if (safe_create_leading_directories(the_repository, ctx->graph_name)) {
2073
}
2074
2075
if (ctx->split) {
2076
- char *lock_name = get_commit_graph_chain_filename(ctx->odb);
2076
+ char *lock_name = get_commit_graph_chain_filename(ctx->odb_source);
2077
2078
hold_lock_file_for_update_mode(&lk, lock_name,
2079
LOCK_DIE_ON_ERROR, 0444);
2161
2162
if (ctx->split && ctx->base_graph_name && ctx->num_commit_graphs_after > 1) {
2163
char *new_base_hash = xstrdup(oid_to_hex(&ctx->new_base_graph->oid));
2164
- char *new_base_name = get_split_graph_filename(ctx->new_base_graph->odb, new_base_hash);
2164
+ char *new_base_name = get_split_graph_filename(ctx->new_base_graph->odb_source, new_base_hash);
2165
2166
free(ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 2]);
2167
free(ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 2]);
2201
}
2202
}
2203
} else {
2204
- char *graph_name = get_commit_graph_filename(ctx->odb);
2204
+ char *graph_name = get_commit_graph_filename(ctx->odb_source);
2205
unlink(graph_name);
2206
free(graph_name);
2207
}
2208
2209
free(ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1]);
2210
ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1] = xstrdup(hash_to_hex(file_hash));
2211
- final_graph_name = get_split_graph_filename(ctx->odb,
2211
+ final_graph_name = get_split_graph_filename(ctx->odb_source,
2212
ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1]);
2213
free(ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 1]);
2214
ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 1] = final_graph_name;
2259
flags != COMMIT_GRAPH_SPLIT_REPLACE) {
2260
while (g && (g->num_commits <= st_mult(size_mult, num_commits) ||
2261
(max_commits && num_commits > max_commits))) {
2262
- if (g->odb != ctx->odb)
2262
+ if (g->odb_source != ctx->odb_source)
2263
break;
2264
2265
if (unsigned_add_overflows(num_commits, g->num_commits))
2281
"should be 1 with --split=replace");
2282
2283
if (ctx->num_commit_graphs_after == 2) {
2284
- char *old_graph_name = get_commit_graph_filename(g->odb);
2284
+ char *old_graph_name = get_commit_graph_filename(g->odb_source);
2285
2286
if (!strcmp(g->filename, old_graph_name) &&
2287
- g->odb != ctx->odb) {
2287
+ g->odb_source != ctx->odb_source) {
2288
ctx->num_commit_graphs_after = 1;
2289
ctx->new_base_graph = NULL;
2290
}
2456
if (ctx->opts && ctx->opts->expire_time)
2457
expire_time = ctx->opts->expire_time;
2458
if (!ctx->split) {
2459
- char *chain_file_name = get_commit_graph_chain_filename(ctx->odb);
2459
+ char *chain_file_name = get_commit_graph_chain_filename(ctx->odb_source);
2460
unlink(chain_file_name);
2461
free(chain_file_name);
2462
ctx->num_commit_graphs_after = 0;
2463
}
2464
2465
- strbuf_addstr(&path, ctx->odb->path);
2465
+ strbuf_addstr(&path, ctx->odb_source->path);
2466
strbuf_addstr(&path, "/info/commit-graphs");
2467
dir = opendir(path.buf);
2468
2504
strbuf_release(&path);
2505
}
2506
2507
-int write_commit_graph(struct object_directory *odb,
2507
+int write_commit_graph(struct odb_source *source,
2508
const struct string_list *const pack_indexes,
2509
struct oidset *commits,
2510
enum commit_graph_write_flags flags,
2513
struct repository *r = the_repository;
2514
struct write_commit_graph_context ctx = {
2515
.r = r,
2516
- .odb = odb,
2516
+ .odb_source = source,
2517
.append = flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0,
2518
.report_progress = flags & COMMIT_GRAPH_WRITE_PROGRESS ? 1 : 0,
2519
.split = flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0,