accepts color.ui boolean values

To configure color, git accepts {auto,never,always} as well as the usual
boolean values {true,false}.

.gitconfig examples:

Always enable colors:
	[color]
		ui = true

Never use colors:
	[color]
		ui = false

Change-Id: I2c309ed8ef1c8b50d0ed283e813dbf64c57d7671
This commit is contained in:
Antoine Musso
2012-01-31 15:20:25 +01:00
parent 62e14dc762
commit 3d6675958f
2 changed files with 5 additions and 2 deletions

View File

@@ -3,3 +3,4 @@ James E. Blair <james.blair@rackspace.com>
Saggi Mizrahi <smizrahi@redhat.com> Saggi Mizrahi <smizrahi@redhat.com>
Kiall Mac Innes <kiall@managedit.ie> Kiall Mac Innes <kiall@managedit.ie>
Roan Kattouw <roan.kattouw@gmail.com> Roan Kattouw <roan.kattouw@gmail.com>
Antoine Musso <hashar@free.fr>

View File

@@ -388,9 +388,11 @@ def assert_one_change(remote, branch, yes, have_hook):
branch_name = get_branch_name(branch) branch_name = get_branch_name(branch)
has_color = check_color_support() has_color = check_color_support()
if has_color: if has_color:
color = git_config_get_value("color", "ui") color = git_config_get_value("color", "ui").lower()
if color == "": if(color == "" or color == "true"):
color = "auto" color = "auto"
elif color == "false":
color = "never"
elif color == "auto": elif color == "auto":
# Python is not a tty, we have to force colors # Python is not a tty, we have to force colors
color = "always" color = "always"