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>
main
Pablo Sabater 2026-07-14 14:09:37 +02:00 committed by Junio C Hamano
parent 233cc40331
commit f3a03302ad
1 changed files with 9 additions and 4 deletions

13
graph.c
View File

@ -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;