Skip to content

Commit 73018c0

Browse files
committed
Merge branch 'mm/color-auto-default'
Flip the default for color.ui to 'auto', which is what many tutorials recommend new users to do. * mm/color-auto-default: make color.ui default to 'auto' config: refactor management of color.ui's default value
2 parents 08bcd77 + 4c7f181 commit 73018c0

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

Documentation/config.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -919,11 +919,12 @@ color.ui::
919919
as `color.diff` and `color.grep` that control the use of color
920920
per command family. Its scope will expand as more commands learn
921921
configuration to set a default for the `--color` option. Set it
922-
to `always` if you want all output not intended for machine
923-
consumption to use color, to `true` or `auto` if you want such
924-
output to use color when written to the terminal, or to `false` or
925-
`never` if you prefer Git commands not to use color unless enabled
926-
explicitly with some other configuration or the `--color` option.
922+
to `false` or `never` if you prefer Git commands not to use
923+
color unless enabled explicitly with some other configuration
924+
or the `--color` option. Set it to `always` if you want all
925+
output not intended for machine consumption to use color, to
926+
`true` or `auto` (this is the default since Git 1.8.4) if you
927+
want such output to use color when written to the terminal.
927928

928929
column.ui::
929930
Specify whether supported commands should output in columns.

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 = GIT_COLOR_AUTO;
346+
342347
get_colorbool_found = want_color(get_colorbool_found);
343348

344349
if (print) {

color.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "cache.h"
22
#include "color.h"
33

4-
static int git_use_color_default = 0;
4+
static int git_use_color_default = GIT_COLOR_AUTO;
55
int color_stdout_is_tty = -1;
66

77
/*

0 commit comments

Comments
 (0)