git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Add two grep config options

From
Joe Ratterman <jratt0@gmail.com>
Date
Mar 25, 2011, 21:21 UTC
Message-ID
<1301088071-918-1-git-send-email-jratt0@gmail.com>

grep.extended-regexp: Enabling this boolean option has the same effect as adding "-E" to all "git grep " instantiations. This can be disabled by specifying "--no-extended-regexp" on a particular call.

grep.line-numbers: Enabling this boolean option has the same effect as adding "-n" to all "git grep " instantiations.

Signed-off-by: Joe Ratterman <jratt0@gmail.com>
---
 Documentation/config.txt   |    6 ++++++
 Documentation/git-grep.txt |    9 +++++++++
 builtin/grep.c             |   10 ++++++++++
 3 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index c5e1835..6b084a8 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1101,6 +1101,12 @@ All gitcvs variables except for 'gitcvs.usecrlfattr' and
 is one of "ext" and "pserver") to make them apply only for the given
 access method.
 
+grep.line-numbers::
+	If set to true, enable '-n' option by default.
+
+grep.extended-regexp::
+	If set to true, enable '--extended-regexp' option by default.
+
 gui.commitmsgwidth::
 	Defines how wide the commit message window is in the
 	linkgit:git-gui[1]. "75" is the default.
diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt
index dab0a78..71668e0 100644
--- a/Documentation/git-grep.txt
+++ b/Documentation/git-grep.txt
@@ -31,6 +31,15 @@ Look for specified patterns in the tracked files in the work tree, blobs
 registered in the index file, or blobs in given tree objects.
 
 
+CONFIGURATION
+-------------
+
+grep.line-numbers::
+	If set to true, enable '-n' option by default.
+
+grep.extended-regexp::
+	If set to true, enable '--extended-regexp' option by default.
+
 OPTIONS
 -------
 --cached::
diff --git a/builtin/grep.c b/builtin/grep.c
index fdf7131..fed9f65 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -303,6 +303,16 @@ static int grep_config(const char *var, const char *value, void *cb)
 	default: return 0;
 	}
 
+	if (!strcmp(var, "grep.extended-regexp")) {
+		opt->regflags = git_config_bool(var, value);
+		return 0;
+	}
+
+	if (!strcmp(var, "grep.line-numbers")) {
+		opt->linenum = git_config_bool(var, value);
+		return 0;
+	}
+
 	if (!strcmp(var, "color.grep"))
 		opt->color = git_config_colorbool(var, value, -1);
 	else if (!strcmp(var, "color.grep.context"))
-- 
1.7.4.1.4.g0ea33
Next: Junio C Hamano
Message 1 of 19 in “Add two grep config options”
  1. Add two grep config optionsJoe Ratterman, Mar 25, 2011
  2. Junio C HamanoMar 25, 2011
  3. Michael J GruberMar 28, 2011
  4. Jeff KingMar 28, 2011
  5. Michael J GruberMar 28, 2011
  6. Jeff KingMar 28, 2011
  7. Junio C HamanoMar 28, 2011
  8. Jeff KingMar 28, 2011
  9. Junio C HamanoMar 28, 2011
  10. Joe RattermanMar 28, 2011
  11. Bert WesargMar 28, 2011
  12. Joe RattermanMar 28, 2011
  13. Junio C HamanoMar 28, 2011
  14. grep: allow -E and -n to be turned on by default via configurationJunio C Hamano, Mar 28, 2011
  15. Junio C HamanoMar 28, 2011
  16. Joe RattermanMar 28, 2011
  17. Junio C HamanoMar 28, 2011
  18. Joe RattermanMar 29, 2011
  19. grep: allow -E and -n to be turned on by default via configurationJoe Ratterman, Mar 30, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.