]> git.ipfire.org Git - thirdparty/git.git/commitdiff
commit-graph: don't pass filename to load_commit_graph_one_fd_st()
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Mon, 25 Mar 2019 12:08:31 +0000 (13:08 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 1 Apr 2019 03:14:50 +0000 (12:14 +0900)
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>
builtin/commit-graph.c
commit-graph.c
commit-graph.h

index 32bcc63427e6c449a436b1fef62a00d920b6355f..8196fdbe9cfac2573ffcbf1435e4fdb6933c64b5 100644 (file)
@@ -64,7 +64,7 @@ static int graph_verify(int argc, const char **argv)
        open_ok = open_commit_graph(graph_name, &fd, &st);
        if (!open_ok)
                return 0;
-       graph = load_commit_graph_one_fd_st(graph_name, fd, &st);
+       graph = load_commit_graph_one_fd_st(fd, &st);
        FREE_AND_NULL(graph_name);
 
        if (!graph)
@@ -102,7 +102,7 @@ static int graph_read(int argc, const char **argv)
        if (!open_ok)
                die_errno(_("Could not open commit-graph '%s'"), graph_name);
 
-       graph = load_commit_graph_one_fd_st(graph_name, fd, &st);
+       graph = load_commit_graph_one_fd_st(fd, &st);
        if (!graph)
                return 1;
 
index 3acc032c1b59d0b35a9422319458613320ca60a5..a26d26666347f2fd404b2bd715c1bae51d2838e1 100644 (file)
@@ -92,8 +92,7 @@ int open_commit_graph(const char *graph_file, int *fd, struct stat *st)
        return 1;
 }
 
-struct commit_graph *load_commit_graph_one_fd_st(const char *graph_file,
-                                                int fd, struct stat *st)
+struct commit_graph *load_commit_graph_one_fd_st(int fd, struct stat *st)
 {
        void *graph_map;
        size_t graph_size;
@@ -103,7 +102,7 @@ struct commit_graph *load_commit_graph_one_fd_st(const char *graph_file,
 
        if (graph_size < GRAPH_MIN_SIZE) {
                close(fd);
-               error(_("graph file %s is too small"), graph_file);
+               error(_("commit-graph file is too small"));
                return NULL;
        }
        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)
        if (!open_ok)
                return NULL;
 
-       return load_commit_graph_one_fd_st(graph_file, fd, &st);
+       return load_commit_graph_one_fd_st(fd, &st);
 }
 
 static void prepare_commit_graph_one(struct repository *r, const char *obj_dir)
index 77cc739bc020a6dfd5425b39313ae7d6299b660c..ada7aea9edb4f53a5bed255a717c4d14b1edfa23 100644 (file)
@@ -53,8 +53,7 @@ struct commit_graph {
        const unsigned char *chunk_extra_edges;
 };
 
-struct commit_graph *load_commit_graph_one_fd_st(const char *graph_file,
-                                                int fd, struct stat *st);
+struct commit_graph *load_commit_graph_one_fd_st(int fd, struct stat *st);
 
 struct commit_graph *parse_commit_graph(void *graph_map, int fd,
                                        size_t graph_size);