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 <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Matthieu Moy committed May 15, 2013 at 19:00 UTC b8612b4da45087d256a0ce339bc65611fb6586f5
1 file changed +5
builtin/config.c
+5
@@ -329,6 +329,7 @@ static int get_colorbool(int print)
329 {
330 get_colorbool_found = -1;
331 get_diff_color_found = -1;
332 + get_color_ui_found = -1;
333 git_config_with_options(git_get_colorbool_config, NULL,
334 given_config_file, respect_includes);
335
@@ -339,6 +340,10 @@ static int get_colorbool(int print)
340 get_colorbool_found = get_color_ui_found;
341 }
342
343 + if (get_colorbool_found < 0)
344 + /* default value if none found in config */
345 + get_colorbool_found = 0;
346 +
347 get_colorbool_found = want_color(get_colorbool_found);
348
349 if (print) {