Skip to content

Commit 69243c2

Browse files
committed
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>
1 parent b4c61ed commit 69243c2

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

builtin-config.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,17 @@ static int get_color(int argc, const char **argv)
210210

211211
static int stdout_is_tty;
212212
static int get_colorbool_found;
213+
static int get_diff_color_found;
213214
static int git_get_colorbool_config(const char *var, const char *value)
214215
{
215-
if (!strcmp(var, get_color_slot))
216+
if (!strcmp(var, get_color_slot)) {
216217
get_colorbool_found =
217218
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+
}
218224
return 0;
219225
}
220226

@@ -233,10 +239,18 @@ static int get_colorbool(int argc, const char **argv)
233239
stdout_is_tty = isatty(1);
234240
else
235241
usage(git_config_set_usage);
236-
get_colorbool_found = 0;
242+
get_colorbool_found = -1;
243+
get_diff_color_found = -1;
237244
get_color_slot = argv[0];
238245
git_config(git_get_colorbool_config);
239246

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+
240254
if (argc == 1) {
241255
return get_colorbool_found ? 0 : 1;
242256
} else {

0 commit comments

Comments
 (0)