grep.c: add configuration variables to show matched option
To support git-grep(1)'s new option, '--column', document and teach grep.c how to interpret relevant configuration options, similar to those associated with '--line-number'. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Taylor Blau committed
Jun 22, 2018 at 10:49 UTC
6653fec3bb969d8be3987cf77654c0aa1778b6b5
3 files changed
+14
Documentation/config.txt
+5
@@ -1183,6 +1183,8 @@ color.grep.<slot>::
1183
function name lines (when using `-p`)
1184
`lineNumber`;;
1185
line number prefix (when using `-n`)
1186
+`column`;;
1187
+ column number prefix (when using `--column`)
1188
`match`;;
1189
matching text (same as setting `matchContext` and `matchSelected`)
1190
`matchContext`;;
@@ -1797,6 +1799,9 @@ gitweb.snapshot::
1799
grep.lineNumber::
1800
If set to true, enable `-n` option by default.
1801
1802
+grep.column::
1803
+ If set to true, enable the `--column` option by default.
1804
+
1805
grep.patternType::
1806
Set the default matching behavior. Using a value of 'basic', 'extended',
1807
'fixed', or 'perl' will enable the `--basic-regexp`, `--extended-regexp`,
Documentation/git-grep.txt
+3
@@ -44,6 +44,9 @@ CONFIGURATION
44
grep.lineNumber::
45
If set to true, enable `-n` option by default.
46
47
+grep.column::
48
+ If set to true, enable the `--column` option by default.
49
+
50
grep.patternType::
51
Set the default matching behavior. Using a value of 'basic', 'extended',
52
'fixed', or 'perl' will enable the `--basic-regexp`, `--extended-regexp`,
grep.c
+6
@@ -96,6 +96,10 @@ int grep_config(const char *var, const char *value, void *cb)
96
opt->linenum = git_config_bool(var, value);
97
return 0;
98
}
99
+ if (!strcmp(var, "grep.column")) {
100
+ opt->columnnum = git_config_bool(var, value);
101
+ return 0;
102
+ }
103
104
if (!strcmp(var, "grep.fullname")) {
105
opt->relative = !git_config_bool(var, value);
@@ -112,6 +116,8 @@ int grep_config(const char *var, const char *value, void *cb)
116
color = opt->color_function;
117
else if (!strcmp(var, "color.grep.linenumber"))
118
color = opt->color_lineno;
119
+ else if (!strcmp(var, "color.grep.column"))
120
+ color = opt->color_columnno;
121
else if (!strcmp(var, "color.grep.matchcontext"))
122
color = opt->color_match_context;
123
else if (!strcmp(var, "color.grep.matchselected"))