Revert "color: make "always" the same as "auto" in config"

This reverts commit 6be4595edb8e5b616c6e8b9fbc78b0f831fa2a87. That commit weakened the "always" setting of color config so that it acted as "auto". This was meant to solve regressions in v2.14.2 in which setting "color.ui=always" in the on-disk config broke scripts like add--interactive, because the plumbing diff commands began to generate color output. This was due to 136c8c8b8f (color: check color.ui in git_default_config(), 2017-07-13), which was in turn trying to fix issues caused by 4c7f1819b3 (make color.ui default to 'auto', 2013-06-10). But in weakening "always", we created even more problems, as people expect to be able to use "git -c color.ui=always" to force color (especially because some commands don't have their own --color flag). We can fix that by special-casing the command-line "-c", but now things are getting pretty confusing. Instead of piling hacks upon hacks, let's start peeling off the hacks. The first step is dropping the weakening of "always", which this revert does. Note that we could actually revert the whole series merged in by da15b78e52642bd45fd5513ab0000fdf2e58a6f4. Most of that series consists of preparations to the tests to handle the weakening of "-c color.ui=always". But it's worth keeping for a few reasons: - there are some other preparatory cleanups, like e433749d86 (test-terminal: set TERM=vt100, 2017-10-03) - it adds "--color" options more consistently in 0c88bf5050 (provide --color option for all ref-filter users, 2017-10-03) - some of the cases dropping "-c" end up being more robust and realistic tests, as in 01c94e9001 (t7508: use test_terminal for color output, 2017-10-03) - the preferred tool for overriding config is "--color", and we should be modeling that consistently We can individually revert the few commits necessary to restore some useful tests (which will be done on top of this patch). Note that this isn't a pure revert; we'll keep the test added in t3701, but mark it as failure for now. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Oct 13, 2017 at 13:23 UTC 2c1acdf6c9f6668dc520e75709af8447587eb4d0
3 files changed +20 -19
Documentation/config.txt
+18 -17
@@ -1052,10 +1052,10 @@ clean.requireForce::
1052
1053 color.branch::
1054 A boolean to enable/disable color in the output of
1055 - linkgit:git-branch[1]. May be set to `false` (or `never`) to
1056 - disable color entirely, `auto` (or `true` or `always`) in which
1057 - case colors are used only when the output is to a terminal. If
1058 - unset, then the value of `color.ui` is used (`auto` by default).
1055 + linkgit:git-branch[1]. May be set to `always`,
1056 + `false` (or `never`) or `auto` (or `true`), in which case colors are used
1057 + only when the output is to a terminal. If unset, then the
1058 + value of `color.ui` is used (`auto` by default).
1059
1060 color.branch.<slot>::
1061 Use customized color for branch coloration. `<slot>` is one of
@@ -1066,11 +1066,12 @@ color.branch.<slot>::
1066
1067 color.diff::
1068 Whether to use ANSI escape sequences to add color to patches.
1069 - If this is set to `true` or `auto`, linkgit:git-diff[1],
1069 + If this is set to `always`, linkgit:git-diff[1],
1070 linkgit:git-log[1], and linkgit:git-show[1] will use color
1071 - when output is to the terminal. The value `always` is a
1072 - historical synonym for `auto`. If unset, then the value of
1073 - `color.ui` is used (`auto` by default).
1071 + for all patches. If it is set to `true` or `auto`, those
1072 + commands will only use color when output is to the terminal.
1073 + If unset, then the value of `color.ui` is used (`auto` by
1074 + default).
1075 +
1076 This does not affect linkgit:git-format-patch[1] or the
1077 'git-diff-{asterisk}' plumbing commands. Can be overridden on the
@@ -1123,12 +1124,12 @@ color.grep.<slot>::
1124 --
1125
1126 color.interactive::
1126 - When set to `true` or `auto`, use colors for interactive prompts
1127 + When set to `always`, always use colors for interactive prompts
1128 and displays (such as those used by "git-add --interactive" and
1128 - "git-clean --interactive") when the output is to the terminal.
1129 - When false (or `never`), never show colors. The value `always`
1130 - is a historical synonym for `auto`. If unset, then the value of
1131 - `color.ui` is used (`auto` by default).
1129 + "git-clean --interactive"). When false (or `never`), never.
1130 + When set to `true` or `auto`, use colors only when the output is
1131 + to the terminal. If unset, then the value of `color.ui` is
1132 + used (`auto` by default).
1133
1134 color.interactive.<slot>::
1135 Use customized color for 'git add --interactive' and 'git clean
@@ -1175,10 +1176,10 @@ color.ui::
1176 configuration to set a default for the `--color` option. Set it
1177 to `false` or `never` if you prefer Git commands not to use
1178 color unless enabled explicitly with some other configuration
1178 - or the `--color` option. Set it to `true` or `auto` to enable
1179 - color when output is written to the terminal (this is also the
1180 - default since Git 1.8.4). The value `always` is a historical
1181 - synonym for `auto`.
1179 + or the `--color` option. Set it to `always` if you want all
1180 + output not intended for machine consumption to use color, to
1181 + `true` or `auto` (this is the default since Git 1.8.4) if you
1182 + want such output to use color when written to the terminal.
1183
1184 column.ui::
1185 Specify whether supported commands should output in columns.
color.c
+1 -1
@@ -308,7 +308,7 @@ int git_config_colorbool(const char *var, const char *value)
308 if (!strcasecmp(value, "never"))
309 return 0;
310 if (!strcasecmp(value, "always"))
311 - return var ? GIT_COLOR_AUTO : 1;
311 + return 1;
312 if (!strcasecmp(value, "auto"))
313 return GIT_COLOR_AUTO;
314 }
t/t3701-add-interactive.sh
+1 -1
@@ -483,7 +483,7 @@ test_expect_success 'hunk-editing handles custom comment char' '
483 git diff --exit-code
484 '
485
486 -test_expect_success 'add -p works even with color.ui=always' '
486 +test_expect_failure 'add -p works even with color.ui=always' '
487 git reset --hard &&
488 echo change >>file &&
489 test_config color.ui always &&