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 <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Mar 25, 2019 at 13:08 UTC
67a530fab3bbd1d4c3390d6f18e35ab10442c015
3 files changed
+6
-8
builtin/commit-graph.c
+2
-2
@@ -64,7 +64,7 @@ static int graph_verify(int argc, const char **argv)
64
open_ok = open_commit_graph(graph_name, &fd, &st);
65
if (!open_ok)
66
return 0;
67
- graph = load_commit_graph_one_fd_st(graph_name, fd, &st);
67
+ graph = load_commit_graph_one_fd_st(fd, &st);
68
FREE_AND_NULL(graph_name);
69
70
if (!graph)
@@ -102,7 +102,7 @@ static int graph_read(int argc, const char **argv)
102
if (!open_ok)
103
die_errno(_("Could not open commit-graph '%s'"), graph_name);
104
105
- graph = load_commit_graph_one_fd_st(graph_name, fd, &st);
105
+ graph = load_commit_graph_one_fd_st(fd, &st);
106
if (!graph)
107
return 1;
108
commit-graph.c
+3
-4
@@ -92,8 +92,7 @@ int open_commit_graph(const char *graph_file, int *fd, struct stat *st)
92
return 1;
93
}
94
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)
96
{
97
void *graph_map;
98
size_t graph_size;
@@ -103,7 +102,7 @@ struct commit_graph *load_commit_graph_one_fd_st(const char *graph_file,
102
103
if (graph_size < GRAPH_MIN_SIZE) {
104
close(fd);
106
- error(_("graph file %s is too small"), graph_file);
105
+ error(_("commit-graph file is too small"));
106
return NULL;
107
}
108
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)
283
if (!open_ok)
284
return NULL;
285
287
- return load_commit_graph_one_fd_st(graph_file, fd, &st);
286
+ return load_commit_graph_one_fd_st(fd, &st);
287
}
288
289
static void prepare_commit_graph_one(struct repository *r, const char *obj_dir)
commit-graph.h
+1
-2
@@ -53,8 +53,7 @@ struct commit_graph {
53
const unsigned char *chunk_extra_edges;
54
};
55
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);
57
58
struct commit_graph *parse_commit_graph(void *graph_map, int fd,
59
size_t graph_size);