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>
maint
Taylor Blau 2018-06-22 10:49:49 -05:00 committed by Junio C Hamano
parent a449f27ffa
commit 6653fec3bb
3 changed files with 14 additions and 0 deletions

View File

@ -1183,6 +1183,8 @@ color.grep.<slot>::
function name lines (when using `-p`) function name lines (when using `-p`)
`lineNumber`;; `lineNumber`;;
line number prefix (when using `-n`) line number prefix (when using `-n`)
`column`;;
column number prefix (when using `--column`)
`match`;; `match`;;
matching text (same as setting `matchContext` and `matchSelected`) matching text (same as setting `matchContext` and `matchSelected`)
`matchContext`;; `matchContext`;;
@ -1797,6 +1799,9 @@ gitweb.snapshot::
grep.lineNumber:: grep.lineNumber::
If set to true, enable `-n` option by default. If set to true, enable `-n` option by default.


grep.column::
If set to true, enable the `--column` option by default.

grep.patternType:: grep.patternType::
Set the default matching behavior. Using a value of 'basic', 'extended', Set the default matching behavior. Using a value of 'basic', 'extended',
'fixed', or 'perl' will enable the `--basic-regexp`, `--extended-regexp`, 'fixed', or 'perl' will enable the `--basic-regexp`, `--extended-regexp`,

View File

@ -44,6 +44,9 @@ CONFIGURATION
grep.lineNumber:: grep.lineNumber::
If set to true, enable `-n` option by default. If set to true, enable `-n` option by default.


grep.column::
If set to true, enable the `--column` option by default.

grep.patternType:: grep.patternType::
Set the default matching behavior. Using a value of 'basic', 'extended', Set the default matching behavior. Using a value of 'basic', 'extended',
'fixed', or 'perl' will enable the `--basic-regexp`, `--extended-regexp`, 'fixed', or 'perl' will enable the `--basic-regexp`, `--extended-regexp`,

6
grep.c
View File

@ -96,6 +96,10 @@ int grep_config(const char *var, const char *value, void *cb)
opt->linenum = git_config_bool(var, value); opt->linenum = git_config_bool(var, value);
return 0; return 0;
} }
if (!strcmp(var, "grep.column")) {
opt->columnnum = git_config_bool(var, value);
return 0;
}


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