Skip to content

Commit b8612b4

Browse files
moygitster
authored andcommitted
config: refactor management of color.ui's default value
The meaning of get_colorbool_found and get_diff_color_found is "the config value if found, and -1 otherwise", but get_color_ui_found had a slightly different meaning, as it has the value 0 (which corresponds to the default value from the user point of view) when color.ui is unset. Make get_color_ui_found default to -1, and make it explicit that 0 is the default value when nothing else is found. Signed-off-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 92758dd commit b8612b4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

builtin/config.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ static int get_colorbool(int print)
329329
{
330330
get_colorbool_found = -1;
331331
get_diff_color_found = -1;
332+
get_color_ui_found = -1;
332333
git_config_with_options(git_get_colorbool_config, NULL,
333334
given_config_file, respect_includes);
334335

@@ -339,6 +340,10 @@ static int get_colorbool(int print)
339340
get_colorbool_found = get_color_ui_found;
340341
}
341342

343+
if (get_colorbool_found < 0)
344+
/* default value if none found in config */
345+
get_colorbool_found = 0;
346+
342347
get_colorbool_found = want_color(get_colorbool_found);
343348

344349
if (print) {

0 commit comments

Comments
 (0)