summaryrefslogtreecommitdiffstats
path: root/main.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2014-12-22 15:17:59 -0500
committerMike Frysinger <vapier@google.com>2014-12-30 18:50:05 -0500
commit902665bce668a58996de657a65c5ae3002a8810b (patch)
tree04d5093d86a398acb3be824cec60b89076674258 /main.py
parent3eb87cec5cae5f43becfe9fd1ff94de855cac08c (diff)
downloadgit-repo-902665bce668a58996de657a65c5ae3002a8810b.tar.gz
add a global --color option
If you want to turn off colors for commands, you have to manually adjust the git config settings (in various locations). If you're writing scripts though, you often don't want to modify those locations. Add a commandline option to explicitly control things. The default behavior is unchanged -- we still scan the config files. Change-Id: I54a3fd8e1918bac180aadd7c7d3004f069b02522
Diffstat (limited to 'main.py')
-rwxr-xr-xmain.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/main.py b/main.py
index 72fb39b0..47f083df 100755
--- a/main.py
+++ b/main.py
@@ -36,6 +36,7 @@ try:
36except ImportError: 36except ImportError:
37 kerberos = None 37 kerberos = None
38 38
39from color import SetDefaultColoring
39from trace import SetTrace 40from trace import SetTrace
40from git_command import git, GitCommand 41from git_command import git, GitCommand
41from git_config import init_ssh, close_ssh 42from git_config import init_ssh, close_ssh
@@ -69,6 +70,9 @@ global_options.add_option('-p', '--paginate',
69global_options.add_option('--no-pager', 70global_options.add_option('--no-pager',
70 dest='no_pager', action='store_true', 71 dest='no_pager', action='store_true',
71 help='disable the pager') 72 help='disable the pager')
73global_options.add_option('--color',
74 choices=('auto', 'always', 'never'), default=None,
75 help='control color usage: auto, always, never')
72global_options.add_option('--trace', 76global_options.add_option('--trace',
73 dest='trace', action='store_true', 77 dest='trace', action='store_true',
74 help='trace git command execution') 78 help='trace git command execution')
@@ -113,6 +117,8 @@ class _Repo(object):
113 print('fatal: invalid usage of --version', file=sys.stderr) 117 print('fatal: invalid usage of --version', file=sys.stderr)
114 return 1 118 return 1
115 119
120 SetDefaultColoring(gopts.color)
121
116 try: 122 try:
117 cmd = self.commands[name] 123 cmd = self.commands[name]
118 except KeyError: 124 except KeyError: