Skip to content

Commit 6653fec

Browse files
ttaylorrgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a449f27 commit 6653fec

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

Documentation/config.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,8 @@ color.grep.<slot>::
11831183
function name lines (when using `-p`)
11841184
`lineNumber`;;
11851185
line number prefix (when using `-n`)
1186+
`column`;;
1187+
column number prefix (when using `--column`)
11861188
`match`;;
11871189
matching text (same as setting `matchContext` and `matchSelected`)
11881190
`matchContext`;;
@@ -1797,6 +1799,9 @@ gitweb.snapshot::
17971799
grep.lineNumber::
17981800
If set to true, enable `-n` option by default.
17991801

1802+
grep.column::
1803+
If set to true, enable the `--column` option by default.
1804+
18001805
grep.patternType::
18011806
Set the default matching behavior. Using a value of 'basic', 'extended',
18021807
'fixed', or 'perl' will enable the `--basic-regexp`, `--extended-regexp`,

Documentation/git-grep.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ CONFIGURATION
4444
grep.lineNumber::
4545
If set to true, enable `-n` option by default.
4646

47+
grep.column::
48+
If set to true, enable the `--column` option by default.
49+
4750
grep.patternType::
4851
Set the default matching behavior. Using a value of 'basic', 'extended',
4952
'fixed', or 'perl' will enable the `--basic-regexp`, `--extended-regexp`,

grep.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ int grep_config(const char *var, const char *value, void *cb)
9696
opt->linenum = git_config_bool(var, value);
9797
return 0;
9898
}
99+
if (!strcmp(var, "grep.column")) {
100+
opt->columnnum = git_config_bool(var, value);
101+
return 0;
102+
}
99103

100104
if (!strcmp(var, "grep.fullname")) {
101105
opt->relative = !git_config_bool(var, value);
@@ -112,6 +116,8 @@ int grep_config(const char *var, const char *value, void *cb)
112116
color = opt->color_function;
113117
else if (!strcmp(var, "color.grep.linenumber"))
114118
color = opt->color_lineno;
119+
else if (!strcmp(var, "color.grep.column"))
120+
color = opt->color_columnno;
115121
else if (!strcmp(var, "color.grep.matchcontext"))
116122
color = opt->color_match_context;
117123
else if (!strcmp(var, "color.grep.matchselected"))

0 commit comments

Comments
 (0)