[PATCH] grep: add configuration variables for --heading

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There are already configuration variables for -n and --column. Add one
for --heading, allowing users to customize the default behaviour.

Signed-off-by: Simon Ser <contact@xxxxxxxxxxx>
---
 Documentation/git-grep.txt | 3 +++
 grep.c                     | 5 +++++
 2 files changed, 8 insertions(+)

diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt
index a7f9bc99eaf1..ed4f05d885a2 100644
--- a/Documentation/git-grep.txt
+++ b/Documentation/git-grep.txt
@@ -47,6 +47,9 @@ grep.lineNumber::
 grep.column::
 	If set to true, enable the `--column` option by default.
 
+grep.heading::
+	If set to true, enable the `--heading` option by default.
+
 grep.patternType::
 	Set the default matching behavior. Using a value of 'basic', 'extended',
 	'fixed', or 'perl' will enable the `--basic-regexp`, `--extended-regexp`,
diff --git a/grep.c b/grep.c
index 13232a904aca..4549bc722650 100644
--- a/grep.c
+++ b/grep.c
@@ -133,6 +133,10 @@ int grep_config(const char *var, const char *value, void *cb)
 		opt->columnnum = git_config_bool(var, value);
 		return 0;
 	}
+	if (!strcmp(var, "grep.heading")) {
+		opt->heading = git_config_bool(var, value);
+		return 0;
+	}
 
 	if (!strcmp(var, "grep.fullname")) {
 		opt->relative = !git_config_bool(var, value);
@@ -199,6 +203,7 @@ void grep_init(struct grep_opt *opt, struct repository *repo, const char *prefix
 	opt->pattern_type_option = def->pattern_type_option;
 	opt->linenum = def->linenum;
 	opt->columnnum = def->columnnum;
+	opt->heading = def->heading;
 	opt->max_depth = def->max_depth;
 	opt->pathname = def->pathname;
 	opt->relative = def->relative;
-- 
2.26.2






[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux