graph: move config reading into graph_read_config()

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>

Pablo Sabater committed Jul 14, 2026 at 14:09 UTC f3a03302ada79d69cf97e601a0cd766330430ef7
1 file changed +9 -4
graph.c
+9 -4
@@ -417,13 +417,11 @@ void graph_setup_line_prefix(struct diff_options *diffopt)
417 diffopt->output_prefix = diff_output_prefix_callback;
418 }
419
420 -struct git_graph *graph_init(struct rev_info *opt)
420 +static void graph_read_config(struct rev_info *revs)
421 {
422 - struct git_graph *graph = xmalloc(sizeof(struct git_graph));
423 -
422 if (!column_colors) {
423 char *string;
426 - if (repo_config_get_string(opt->repo, "log.graphcolors", &string)) {
424 + if (repo_config_get_string(revs->repo, "log.graphcolors", &string)) {
425 /* not configured -- use default */
426 graph_set_column_colors(column_colors_ansi,
427 column_colors_ansi_max);
@@ -437,6 +435,13 @@ struct git_graph *graph_init(struct rev_info *opt)
435 custom_colors.nr - 1);
436 }
437 }
438 +}
439 +
440 +struct git_graph *graph_init(struct rev_info *opt)
441 +{
442 + struct git_graph *graph = xmalloc(sizeof(struct git_graph));
443 +
444 + graph_read_config(opt);
445
446 graph->commit = NULL;
447 graph->revs = opt;