Skip to content

Commit 67a530f

Browse files
avargitster
authored andcommitted
commit-graph: don't pass filename to load_commit_graph_one_fd_st()
An earlier change implemented load_commit_graph_one_fd_st() in a way that was bug-compatible with earlier code in terms of the "graph file %s is too small" error message printing out the path to the commit-graph (".git/objects/info/commit-graph"). But change that, because: * A function that takes an already-open file descriptor also needing the filename isn't very intuitive. * The vast majority of errors we might emit when loading the graph come from parse_commit_graph(), which doesn't report the filename. Let's not do that either in this case for consistency. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 61df89c commit 67a530f

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

builtin/commit-graph.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static int graph_verify(int argc, const char **argv)
6464
open_ok = open_commit_graph(graph_name, &fd, &st);
6565
if (!open_ok)
6666
return 0;
67-
graph = load_commit_graph_one_fd_st(graph_name, fd, &st);
67+
graph = load_commit_graph_one_fd_st(fd, &st);
6868
FREE_AND_NULL(graph_name);
6969

7070
if (!graph)
@@ -102,7 +102,7 @@ static int graph_read(int argc, const char **argv)
102102
if (!open_ok)
103103
die_errno(_("Could not open commit-graph '%s'"), graph_name);
104104

105-
graph = load_commit_graph_one_fd_st(graph_name, fd, &st);
105+
graph = load_commit_graph_one_fd_st(fd, &st);
106106
if (!graph)
107107
return 1;
108108

commit-graph.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ int open_commit_graph(const char *graph_file, int *fd, struct stat *st)
9292
return 1;
9393
}
9494

95-
struct commit_graph *load_commit_graph_one_fd_st(const char *graph_file,
96-
int fd, struct stat *st)
95+
struct commit_graph *load_commit_graph_one_fd_st(int fd, struct stat *st)
9796
{
9897
void *graph_map;
9998
size_t graph_size;
@@ -103,7 +102,7 @@ struct commit_graph *load_commit_graph_one_fd_st(const char *graph_file,
103102

104103
if (graph_size < GRAPH_MIN_SIZE) {
105104
close(fd);
106-
error(_("graph file %s is too small"), graph_file);
105+
error(_("commit-graph file is too small"));
107106
return NULL;
108107
}
109108
graph_map = xmmap(NULL, graph_size, PROT_READ, MAP_PRIVATE, fd, 0);
@@ -284,7 +283,7 @@ static struct commit_graph *load_commit_graph_one(const char *graph_file)
284283
if (!open_ok)
285284
return NULL;
286285

287-
return load_commit_graph_one_fd_st(graph_file, fd, &st);
286+
return load_commit_graph_one_fd_st(fd, &st);
288287
}
289288

290289
static void prepare_commit_graph_one(struct repository *r, const char *obj_dir)

commit-graph.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ struct commit_graph {
5353
const unsigned char *chunk_extra_edges;
5454
};
5555

56-
struct commit_graph *load_commit_graph_one_fd_st(const char *graph_file,
57-
int fd, struct stat *st);
56+
struct commit_graph *load_commit_graph_one_fd_st(int fd, struct stat *st);
5857

5958
struct commit_graph *parse_commit_graph(void *graph_map, int fd,
6059
size_t graph_size);

0 commit comments

Comments
 (0)