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

[PATCH 1/4 (alternate)] Add '--fixed-strings' option to "git log --grep" and friends

From
Jakub Narebski <jnareb@gmail.com>
Date
Feb 27, 2008, 09:20 UTC
Message-ID
<200802271020.21662.jnareb@gmail.com>
In-Reply-To
<7vfxvf2osk.fsf@gitster.siamese.dyndns.org>

Add support for '--fixed-strings' option to "git log --grep" and friends: "git log --author", "git log --committer". Code is based on implementation of this option in "git grep".

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
On Wed, 27 Feb 2008, Junio C Hamano wrote:
> So I am reluctant to
> see it grab a short-and-sweet -F option letter that might have
> better uses, but I do not have major objection against a more
> explicit --fixed-strings.
This version doesn't use '-F' short option.
 Documentation/git-rev-list.txt     |    1 +
 Documentation/rev-list-options.txt |    5 +++++
 revision.c                         |    9 ++++++++-
 3 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt
index 5b96eab..0291225 100644
--- a/Documentation/git-rev-list.txt
+++ b/Documentation/git-rev-list.txt
@@ -31,6 +31,7 @@ SYNOPSIS
 	     [ \--(author|committer|grep)=<pattern> ]
 	     [ \--regexp-ignore-case | \-i ]
 	     [ \--extended-regexp | \-E ]
+	     [ \--fixed-strings ]
 	     [ \--date={local|relative|default|iso|rfc|short} ]
 	     [ [\--objects | \--objects-edge] [ \--unpacked ] ]
 	     [ \--pretty | \--header ]
diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
index a8138e2..826ac62 100644
--- a/Documentation/rev-list-options.txt
+++ b/Documentation/rev-list-options.txt
@@ -153,6 +153,11 @@ limiting may be applied.
 	Consider the limiting patterns to be extended regular expressions
 	instead of the default basic regular expressions.
 
+--fixed-strings::
+
+	Consider the limiting patterns to be fixed strings (don't interpret
+	pattern as a regular expression).
+
 --remove-empty::
 
 	Stop when a given path disappears from the tree.
diff --git a/revision.c b/revision.c
index d3e8658..4daeac1 100644
--- a/revision.c
+++ b/revision.c
@@ -942,6 +942,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
 	int left = 1;
 	int all_match = 0;
 	int regflags = 0;
+	int fixed = 0;
 
 	/* First, search for "--" */
 	seen_dashdash = 0;
@@ -1238,6 +1239,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
 				regflags |= REG_ICASE;
 				continue;
 			}
+			if (!strcmp(arg, "--fixed-strings")) {
+				fixed = 1;
+				continue;
+			}
 			if (!strcmp(arg, "--all-match")) {
 				all_match = 1;
 				continue;
@@ -1293,8 +1298,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
 		}
 	}
 
-	if (revs->grep_filter)
+	if (revs->grep_filter) {
 		revs->grep_filter->regflags |= regflags;
+		revs->grep_filter->fixed = fixed;
+	}
 
 	if (show_merge)
 		prepare_show_merge(revs);
-- 
1.5.4.2
Previous: Jakub NarebskiNext: Junio C Hamano
Message 5 of 9 in “Improve gitweb search, and other things”
  1. 0/4 Improve gitweb search, and other thingsJakub Narebski, Feb 26, 2008
  2. 1/4 Add '--fixed-strings' option to "git log --grep" and friendsJakub Narebski, Feb 26, 2008
  3. Junio C HamanoFeb 27, 2008
  4. Jakub NarebskiFeb 27, 2008
  5. 1/4 Add '--fixed-strings' option to "git log --grep" and friendsJakub Narebski, Feb 27, 2008
  6. Junio C HamanoFeb 27, 2008
  7. 2/4 gitweb: Change parse_commits signature to allow for multiple optionsJakub Narebski, Feb 26, 2008
  8. 3/4 gitweb: Simplify fixed string searchJakub Narebski, Feb 26, 2008
  9. 4/4 gitweb: Clearly distinguish regexp / exact match searchesJakub Narebski, Feb 26, 2008

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.