Skip to content

Commit ab14d06

Browse files
ttaylorrgitster
authored andcommitted
commit-graph: pass a 'struct repository *' in more places
In a future commit, some commit-graph internals will want access to 'r->settings', but we only have the 'struct object_directory *' corresponding to that repository. Add an additional parameter to pass the repository around in more places. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 025d529 commit ab14d06

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

builtin/commit-graph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static int graph_verify(int argc, const char **argv)
106106
FREE_AND_NULL(graph_name);
107107

108108
if (open_ok)
109-
graph = load_commit_graph_one_fd_st(fd, &st, odb);
109+
graph = load_commit_graph_one_fd_st(the_repository, fd, &st, odb);
110110
else
111111
graph = read_commit_graph_one(the_repository, odb);
112112

commit-graph.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ int open_commit_graph(const char *graph_file, int *fd, struct stat *st)
224224
return 1;
225225
}
226226

227-
struct commit_graph *load_commit_graph_one_fd_st(int fd, struct stat *st,
227+
struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,
228+
int fd, struct stat *st,
228229
struct object_directory *odb)
229230
{
230231
void *graph_map;
@@ -240,7 +241,7 @@ struct commit_graph *load_commit_graph_one_fd_st(int fd, struct stat *st,
240241
}
241242
graph_map = xmmap(NULL, graph_size, PROT_READ, MAP_PRIVATE, fd, 0);
242243
close(fd);
243-
ret = parse_commit_graph(graph_map, graph_size);
244+
ret = parse_commit_graph(r, graph_map, graph_size);
244245

245246
if (ret)
246247
ret->odb = odb;
@@ -280,7 +281,8 @@ static int verify_commit_graph_lite(struct commit_graph *g)
280281
return 0;
281282
}
282283

283-
struct commit_graph *parse_commit_graph(void *graph_map, size_t graph_size)
284+
struct commit_graph *parse_commit_graph(struct repository *r,
285+
void *graph_map, size_t graph_size)
284286
{
285287
const unsigned char *data, *chunk_lookup;
286288
uint32_t i;
@@ -445,7 +447,8 @@ struct commit_graph *parse_commit_graph(void *graph_map, size_t graph_size)
445447
return NULL;
446448
}
447449

448-
static struct commit_graph *load_commit_graph_one(const char *graph_file,
450+
static struct commit_graph *load_commit_graph_one(struct repository *r,
451+
const char *graph_file,
449452
struct object_directory *odb)
450453
{
451454

@@ -457,7 +460,7 @@ static struct commit_graph *load_commit_graph_one(const char *graph_file,
457460
if (!open_ok)
458461
return NULL;
459462

460-
g = load_commit_graph_one_fd_st(fd, &st, odb);
463+
g = load_commit_graph_one_fd_st(r, fd, &st, odb);
461464

462465
if (g)
463466
g->filename = xstrdup(graph_file);
@@ -469,7 +472,7 @@ static struct commit_graph *load_commit_graph_v1(struct repository *r,
469472
struct object_directory *odb)
470473
{
471474
char *graph_name = get_commit_graph_filename(odb);
472-
struct commit_graph *g = load_commit_graph_one(graph_name, odb);
475+
struct commit_graph *g = load_commit_graph_one(r, graph_name, odb);
473476
free(graph_name);
474477

475478
return g;
@@ -550,7 +553,7 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r,
550553
valid = 0;
551554
for (odb = r->objects->odb; odb; odb = odb->next) {
552555
char *graph_name = get_split_graph_filename(odb, line.buf);
553-
struct commit_graph *g = load_commit_graph_one(graph_name, odb);
556+
struct commit_graph *g = load_commit_graph_one(r, graph_name, odb);
554557

555558
free(graph_name);
556559

commit-graph.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,13 @@ struct commit_graph {
7575
struct bloom_filter_settings *bloom_filter_settings;
7676
};
7777

78-
struct commit_graph *load_commit_graph_one_fd_st(int fd, struct stat *st,
78+
struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,
79+
int fd, struct stat *st,
7980
struct object_directory *odb);
8081
struct commit_graph *read_commit_graph_one(struct repository *r,
8182
struct object_directory *odb);
82-
struct commit_graph *parse_commit_graph(void *graph_map, size_t graph_size);
83+
struct commit_graph *parse_commit_graph(struct repository *r,
84+
void *graph_map, size_t graph_size);
8385

8486
/*
8587
* Return 1 if and only if the repository has a commit-graph

fuzz-commit-graph.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#include "commit-graph.h"
22
#include "repository.h"
33

4-
struct commit_graph *parse_commit_graph(void *graph_map, size_t graph_size);
4+
struct commit_graph *parse_commit_graph(struct repository *r,
5+
void *graph_map, size_t graph_size);
56

67
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
78

@@ -10,7 +11,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
1011
struct commit_graph *g;
1112

1213
initialize_the_repository();
13-
g = parse_commit_graph((void *)data, size);
14+
g = parse_commit_graph(the_repository, (void *)data, size);
1415
repo_clear(the_repository);
1516
free_commit_graph(g);
1617

0 commit comments

Comments
 (0)