summaryrefslogtreecommitdiffstats
path: root/subcmds
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2009-06-12 09:33:48 -0700
committerShawn O. Pearce <sop@google.com>2009-06-12 09:33:48 -0700
commitf0d4c36701613dc9c305208d81b139208e40414c (patch)
treee33abb1c63aeacd3160aad4301025b4cde056208 /subcmds
parent2ec00b92724982708071dc0eed707659468d2bcf (diff)
downloadgit-repo-f0d4c36701613dc9c305208d81b139208e40414c.tar.gz
grep: Only use --color on git 1.6.3 and later
The --color flag wasn't introduced until git 1.6.3. Prior to that version, `git grep --color` just produces a fatal error, as it is an unsupported option. Since this is just pretty output and is not critical to execution, we can simply omit the option if the version of git we are running on doesn't support it. Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'subcmds')
-rw-r--r--subcmds/grep.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/subcmds/grep.py b/subcmds/grep.py
index 950cc155..4f714271 100644
--- a/subcmds/grep.py
+++ b/subcmds/grep.py
@@ -17,7 +17,7 @@ import sys
17from optparse import SUPPRESS_HELP 17from optparse import SUPPRESS_HELP
18from color import Coloring 18from color import Coloring
19from command import PagedCommand 19from command import PagedCommand
20from git_command import GitCommand 20from git_command import git_require, GitCommand
21 21
22class GrepColoring(Coloring): 22class GrepColoring(Coloring):
23 def __init__(self, config): 23 def __init__(self, config):
@@ -158,7 +158,7 @@ contain a line that matches both expressions:
158 out = GrepColoring(self.manifest.manifestProject.config) 158 out = GrepColoring(self.manifest.manifestProject.config)
159 159
160 cmd_argv = ['grep'] 160 cmd_argv = ['grep']
161 if out.is_on: 161 if out.is_on and git_require((1,6,3)):
162 cmd_argv.append('--color') 162 cmd_argv.append('--color')
163 cmd_argv.extend(getattr(opt,'cmd_argv',[])) 163 cmd_argv.extend(getattr(opt,'cmd_argv',[]))
164 164