44
/* Remember to update object flag allocation in object.h */
45
#define REACHABLE (1u<<15)
46
47
-char *get_commit_graph_filename(const char *obj_dir)
47
+char *get_commit_graph_filename(struct object_directory *odb)
48
{
49
- char *filename = xstrfmt("%s/info/commit-graph", obj_dir);
50
- char *normalized = xmalloc(strlen(filename) + 1);
51
- normalize_path_copy(normalized, filename);
52
- free(filename);
53
- return normalized;
49
+ return xstrfmt("%s/info/commit-graph", odb->path);
50
}
51
56
-static char *get_split_graph_filename(const char *obj_dir,
52
+static char *get_split_graph_filename(struct object_directory *odb,
53
const char *oid_hex)
54
{
59
- char *filename = xstrfmt("%s/info/commit-graphs/graph-%s.graph",
60
- obj_dir,
61
- oid_hex);
62
- char *normalized = xmalloc(strlen(filename) + 1);
63
- normalize_path_copy(normalized, filename);
64
- free(filename);
65
- return normalized;
55
+ return xstrfmt("%s/info/commit-graphs/graph-%s.graph", odb->path,
56
+ oid_hex);
57
}
58
68
-static char *get_chain_filename(const char *obj_dir)
59
+static char *get_chain_filename(struct object_directory *odb)
60
{
70
- return xstrfmt("%s/info/commit-graphs/commit-graph-chain", obj_dir);
61
+ return xstrfmt("%s/info/commit-graphs/commit-graph-chain", odb->path);
62
}
63
64
static uint8_t oid_version(void)
321
static struct commit_graph *load_commit_graph_v1(struct repository *r,
322
struct object_directory *odb)
323
{
333
- char *graph_name = get_commit_graph_filename(odb->path);
324
+ char *graph_name = get_commit_graph_filename(odb);
325
struct commit_graph *g = load_commit_graph_one(graph_name);
326
free(graph_name);
327
372
struct stat st;
373
struct object_id *oids;
374
int i = 0, valid = 1, count;
384
- char *chain_name = get_chain_filename(odb->path);
375
+ char *chain_name = get_chain_filename(odb);
376
FILE *fp;
377
int stat_res;
378
405
406
valid = 0;
407
for (odb = r->objects->odb; odb; odb = odb->next) {
417
- char *graph_name = get_split_graph_filename(odb->path, line.buf);
408
+ char *graph_name = get_split_graph_filename(odb, line.buf);
409
struct commit_graph *g = load_commit_graph_one(graph_name);
410
411
free(graph_name);
1366
ctx->odb->path);
1367
ctx->graph_name = strbuf_detach(&tmp_file, NULL);
1368
} else {
1378
- ctx->graph_name = get_commit_graph_filename(ctx->odb->path);
1369
+ ctx->graph_name = get_commit_graph_filename(ctx->odb);
1370
}
1371
1372
if (safe_create_leading_directories(ctx->graph_name)) {
1377
}
1378
1379
if (ctx->split) {
1389
- char *lock_name = get_chain_filename(ctx->odb->path);
1380
+ char *lock_name = get_chain_filename(ctx->odb);
1381
1382
hold_lock_file_for_update(&lk, lock_name, LOCK_DIE_ON_ERROR);
1383
1465
1466
if (ctx->split && ctx->base_graph_name && ctx->num_commit_graphs_after > 1) {
1467
char *new_base_hash = xstrdup(oid_to_hex(&ctx->new_base_graph->oid));
1477
- char *new_base_name = get_split_graph_filename(ctx->new_base_graph->odb->path, new_base_hash);
1468
+ char *new_base_name = get_split_graph_filename(ctx->new_base_graph->odb, new_base_hash);
1469
1470
free(ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 2]);
1471
free(ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 2]);
1501
}
1502
}
1503
} else {
1513
- char *graph_name = get_commit_graph_filename(ctx->odb->path);
1504
+ char *graph_name = get_commit_graph_filename(ctx->odb);
1505
unlink(graph_name);
1506
}
1507
1508
ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1] = xstrdup(oid_to_hex(&file_hash));
1518
- final_graph_name = get_split_graph_filename(ctx->odb->path,
1509
+ final_graph_name = get_split_graph_filename(ctx->odb,
1510
ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1]);
1511
ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 1] = final_graph_name;
1512
1548
1549
while (g && (g->num_commits <= size_mult * num_commits ||
1550
(max_commits && num_commits > max_commits))) {
1560
- if (strcmp(g->odb->path, ctx->odb->path))
1551
+ if (g->odb != ctx->odb)
1552
break;
1553
1554
num_commits += g->num_commits;
1560
ctx->new_base_graph = g;
1561
1562
if (ctx->num_commit_graphs_after == 2) {
1572
- char *old_graph_name = get_commit_graph_filename(g->odb->path);
1563
+ char *old_graph_name = get_commit_graph_filename(g->odb);
1564
1565
if (!strcmp(g->filename, old_graph_name) &&
1575
- strcmp(g->odb->path, ctx->odb->path)) {
1566
+ g->odb != ctx->odb) {
1567
ctx->num_commit_graphs_after = 1;
1568
ctx->new_base_graph = NULL;
1569
}
1714
if (ctx->split_opts && ctx->split_opts->expire_time)
1715
expire_time -= ctx->split_opts->expire_time;
1716
if (!ctx->split) {
1726
- char *chain_file_name = get_chain_filename(ctx->odb->path);
1717
+ char *chain_file_name = get_chain_filename(ctx->odb);
1718
unlink(chain_file_name);
1719
free(chain_file_name);
1720
ctx->num_commit_graphs_after = 0;