git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 1/2] config: refactor management of color.ui's default value
@ 2013-06-10 14:26 Matthieu Moy
  2013-06-10 14:26 ` [PATCH 2/2] make color.ui default to 'auto' Matthieu Moy
  2013-06-10 20:50 ` [PATCH 1/2] config: refactor management of color.ui's default value Junio C Hamano
  0 siblings, 2 replies; 3+ messages in thread
From: Matthieu Moy @ 2013-06-10 14:26 UTC (permalink / raw)
  To: git, gitster; +Cc: Matthieu Moy

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>
---
This one is just a resend of what's already in pu.

 builtin/config.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/builtin/config.c b/builtin/config.c
index 33c9bf9..057bb61 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -329,6 +329,7 @@ static int get_colorbool(int print)
 {
 	get_colorbool_found = -1;
 	get_diff_color_found = -1;
+	get_color_ui_found = -1;
 	git_config_with_options(git_get_colorbool_config, NULL,
 				given_config_file, respect_includes);
 
@@ -339,6 +340,10 @@ static int get_colorbool(int print)
 			get_colorbool_found = get_color_ui_found;
 	}
 
+	if (get_colorbool_found < 0)
+		/* default value if none found in config */
+		get_colorbool_found = 0;
+
 	get_colorbool_found = want_color(get_colorbool_found);
 
 	if (print) {
-- 
1.8.3.rc3.8.g5e49f30

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] make color.ui default to 'auto'
  2013-06-10 14:26 [PATCH 1/2] config: refactor management of color.ui's default value Matthieu Moy
@ 2013-06-10 14:26 ` Matthieu Moy
  2013-06-10 20:50 ` [PATCH 1/2] config: refactor management of color.ui's default value Junio C Hamano
  1 sibling, 0 replies; 3+ messages in thread
From: Matthieu Moy @ 2013-06-10 14:26 UTC (permalink / raw)
  To: git, gitster; +Cc: Matthieu Moy

Most users seem to like having colors enabled, and colors can help
beginners to understand the output of some commands (e.g. notice
immediately the boundary between commits in the output of "git log").

Many tutorials tell the users to set color.ui=auto as a very first step,
which tend to indicate that color.ui=none is not the recommanded value,
hence should not be the default.

These tutorials would benefit from skipping this step and starting the
real Git manipulations earlier. Other beginners do not know about
color.ui=auto, and may not discover it by themselves, hence live with
black&white outputs while they may have preferred colors.

A few people (e.g. color-blind) prefer having no colors, but they can
easily set color.ui=never for this (and googling "disable colors in git"
already tells them how to do so), but this needs not occupy space in
beginner-oriented documentations.

A transition period with Git emitting a warning when color.ui is unset
would be possible, but the discomfort of having the warning seems
superior to the benefit: users may be surprised by the change, but not
harmed by it.

The default value is changed, and the documentation is reworded to
mention "color.ui=false" first, since the primary use of color.ui after
this change is to disable colors, not to enable it.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
I just changed "Git 2.0" with "Git 1.8.4". I think a default change
deserves a mention of the version in which it changed (I think it's
common for someone to use an old Git version and to read a more recent
documentation online, so this may avoid bad surprises). I'm fine with
dropping "since Git 1.8.4" completely if people think it's better.

 Documentation/config.txt | 11 ++++++-----
 builtin/config.c         |  2 +-
 color.c                  |  2 +-
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index e97facc..6570aee 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -905,11 +905,12 @@ color.ui::
 	as `color.diff` and `color.grep` that control the use of color
 	per command family. Its scope will expand as more commands learn
 	configuration to set a default for the `--color` option.  Set it
-	to `always` if you want all output not intended for machine
-	consumption to use color, to `true` or `auto` if you want such
-	output to use color when written to the terminal, or to `false` or
-	`never` if you prefer Git commands not to use color unless enabled
-	explicitly with some other configuration or the `--color` option.
+	to `false` or `never` if you prefer Git commands not to use
+	color unless enabled explicitly with some other configuration
+	or the `--color` option. Set it to `always` if you want all
+	output not intended for machine consumption to use color, to
+	`true` or `auto` (this is the default since Git 1.8.4) if you
+	want such output to use color when written to the terminal.
 
 column.ui::
 	Specify whether supported commands should output in columns.
diff --git a/builtin/config.c b/builtin/config.c
index 057bb61..753449f 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -342,7 +342,7 @@ static int get_colorbool(int print)
 
 	if (get_colorbool_found < 0)
 		/* default value if none found in config */
-		get_colorbool_found = 0;
+		get_colorbool_found = GIT_COLOR_AUTO;
 
 	get_colorbool_found = want_color(get_colorbool_found);
 
diff --git a/color.c b/color.c
index e8e2681..f672885 100644
--- a/color.c
+++ b/color.c
@@ -1,7 +1,7 @@
 #include "cache.h"
 #include "color.h"
 
-static int git_use_color_default = 0;
+static int git_use_color_default = GIT_COLOR_AUTO;
 int color_stdout_is_tty = -1;
 
 /*
-- 
1.8.3.rc3.8.g5e49f30

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] config: refactor management of color.ui's default value
  2013-06-10 14:26 [PATCH 1/2] config: refactor management of color.ui's default value Matthieu Moy
  2013-06-10 14:26 ` [PATCH 2/2] make color.ui default to 'auto' Matthieu Moy
@ 2013-06-10 20:50 ` Junio C Hamano
  1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2013-06-10 20:50 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-06-10 20:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-10 14:26 [PATCH 1/2] config: refactor management of color.ui's default value Matthieu Moy
2013-06-10 14:26 ` [PATCH 2/2] make color.ui default to 'auto' Matthieu Moy
2013-06-10 20:50 ` [PATCH 1/2] config: refactor management of color.ui's default value Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).