]> git.ipfire.org Git - thirdparty/git.git/commitdiff
graph: move config reading into graph_read_config()
authorPablo Sabater <pabloosabaterr@gmail.com>
Tue, 14 Jul 2026 12:09:37 +0000 (14:09 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 14 Jul 2026 14:32:51 +0000 (07:32 -0700)
Move the repo_config_get_string() call out of graph_init() and into
graph_read_config(). This simplifies graph_init() and provides a
function for future graph-related config opt.

This commit is a preparatory commit for a subsequent one.

Signed-off-by: Pablo Sabater <pabloosabaterr@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
graph.c

diff --git a/graph.c b/graph.c
index e3e206170c8453074ac751d3b48e20bc1118d3ea..c14be934a05d4f53c38b3520a9d0ebcdb11e3811 100644 (file)
--- a/graph.c
+++ b/graph.c
@@ -417,13 +417,11 @@ void graph_setup_line_prefix(struct diff_options *diffopt)
                diffopt->output_prefix = diff_output_prefix_callback;
 }
 
-struct git_graph *graph_init(struct rev_info *opt)
+static void graph_read_config(struct rev_info *revs)
 {
-       struct git_graph *graph = xmalloc(sizeof(struct git_graph));
-
        if (!column_colors) {
                char *string;
-               if (repo_config_get_string(opt->repo, "log.graphcolors", &string)) {
+               if (repo_config_get_string(revs->repo, "log.graphcolors", &string)) {
                        /* not configured -- use default */
                        graph_set_column_colors(column_colors_ansi,
                                                column_colors_ansi_max);
@@ -437,6 +435,13 @@ struct git_graph *graph_init(struct rev_info *opt)
                                                custom_colors.nr - 1);
                }
        }
+}
+
+struct git_graph *graph_init(struct rev_info *opt)
+{
+       struct git_graph *graph = xmalloc(sizeof(struct git_graph));
+
+       graph_read_config(opt);
 
        graph->commit = NULL;
        graph->revs = opt;