config --get-colorbool: diff.color is a deprecated synonym to color.diff
The applications can ask for color.diff but the configuration of old timer users can still instruct it to use color with diff.color this way. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Dec 5, 2007 at 22:12 UTC
69243c2b956d69636ae04c184bc8063a6fab728a
1 file changed
+16
-2
builtin-config.c
+16
-2
@@ -210,11 +210,17 @@ static int get_color(int argc, const char **argv)
210
211
static int stdout_is_tty;
212
static int get_colorbool_found;
213
+static int get_diff_color_found;
214
static int git_get_colorbool_config(const char *var, const char *value)
215
{
215
- if (!strcmp(var, get_color_slot))
216
+ if (!strcmp(var, get_color_slot)) {
217
get_colorbool_found =
218
git_config_colorbool(var, value, stdout_is_tty);
219
+ }
220
+ if (!strcmp(var, "diff.color")) {
221
+ get_diff_color_found =
222
+ git_config_colorbool(var, value, stdout_is_tty);
223
+ }
224
return 0;
225
}
226
@@ -233,10 +239,18 @@ static int get_colorbool(int argc, const char **argv)
239
stdout_is_tty = isatty(1);
240
else
241
usage(git_config_set_usage);
236
- get_colorbool_found = 0;
242
+ get_colorbool_found = -1;
243
+ get_diff_color_found = -1;
244
get_color_slot = argv[0];
245
git_config(git_get_colorbool_config);
246
247
+ if (get_colorbool_found < 0) {
248
+ if (!strcmp(get_color_slot, "color.diff"))
249
+ get_colorbool_found = get_diff_color_found;
250
+ if (get_colorbool_found < 0)
251
+ get_colorbool_found = 0;
252
+ }
253
+
254
if (argc == 1) {
255
return get_colorbool_found ? 0 : 1;
256
} else {