320
struct commit_graph *g = load_commit_graph_one(graph_name);
321
free(graph_name);
322
323
+ if (g)
324
+ g->obj_dir = obj_dir;
325
+
326
return g;
327
}
328
382
count = st.st_size / (the_hash_algo->hexsz + 1);
383
oids = xcalloc(count, sizeof(struct object_id));
384
382
- for (i = 0; i < count && valid; i++) {
383
- char *graph_name;
384
- struct commit_graph *g;
385
+ prepare_alt_odb(r);
386
+
387
+ for (i = 0; i < count; i++) {
388
+ struct object_directory *odb;
389
390
if (strbuf_getline_lf(&line, fp) == EOF)
391
break;
397
break;
398
}
399
396
- graph_name = get_split_graph_filename(obj_dir, line.buf);
397
- g = load_commit_graph_one(graph_name);
398
- free(graph_name);
400
+ valid = 0;
401
+ for (odb = r->objects->odb; odb; odb = odb->next) {
402
+ char *graph_name = get_split_graph_filename(odb->path, line.buf);
403
+ struct commit_graph *g = load_commit_graph_one(graph_name);
404
400
- if (g && add_graph_to_chain(g, graph_chain, oids, i))
401
- graph_chain = g;
402
- else
403
- valid = 0;
405
+ free(graph_name);
406
+
407
+ if (g) {
408
+ g->obj_dir = odb->path;
409
+
410
+ if (add_graph_to_chain(g, graph_chain, oids, i)) {
411
+ graph_chain = g;
412
+ valid = 1;
413
+ }
414
+
415
+ break;
416
+ }
417
+ }
418
+
419
+ if (!valid) {
420
+ warning(_("unable to find all commit-graph files"));
421
+ break;
422
+ }
423
}
424
425
free(oids);
1437
1438
if (ctx->split && ctx->base_graph_name && ctx->num_commit_graphs_after > 1) {
1439
char *new_base_hash = xstrdup(oid_to_hex(&ctx->new_base_graph->oid));
1421
- char *new_base_name = get_split_graph_filename(ctx->obj_dir, new_base_hash);
1440
+ char *new_base_name = get_split_graph_filename(ctx->new_base_graph->obj_dir, new_base_hash);
1441
1442
free(ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 2]);
1443
free(ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 2]);
1512
1513
while (g && (g->num_commits <= split_strategy_size_mult * num_commits ||
1514
num_commits > split_strategy_max_commits)) {
1515
+ if (strcmp(g->obj_dir, ctx->obj_dir))
1516
+ break;
1517
+
1518
num_commits += g->num_commits;
1519
g = g->base_graph;
1520
1523
1524
ctx->new_base_graph = g;
1525
1526
+ if (ctx->num_commit_graphs_after == 2) {
1527
+ char *old_graph_name = get_commit_graph_filename(g->obj_dir);
1528
+
1529
+ if (!strcmp(g->filename, old_graph_name) &&
1530
+ strcmp(g->obj_dir, ctx->obj_dir)) {
1531
+ ctx->num_commit_graphs_after = 1;
1532
+ ctx->new_base_graph = NULL;
1533
+ }
1534
+
1535
+ free(old_graph_name);
1536
+ }
1537
+
1538
ALLOC_ARRAY(ctx->commit_graph_filenames_after, ctx->num_commit_graphs_after);
1539
ALLOC_ARRAY(ctx->commit_graph_hash_after, ctx->num_commit_graphs_after);
1540