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

Re: git rev-list --author/--committer b0rked with -F/--fixed-strings

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 4, 2008, 07:12 UTC
Message-ID
<7v4p4w75b7.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<g9o0ac$qig$1@ger.gmane.org>
Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:
> So, is this a known bug (I would call it a bug, yes) in rev-list?
> Are there any ideas around on how to fix it?

It depends on what you are trying to do. An obvious thing to do is to accept the fact that it has always been a regexp match, and quotemeta your input string.

Because we allow you to give "-F" and "--author=foo" in any order, looking at the options we have seen already and adjusting the pattern depending on the fixed-string option in the code would not be workable. You would have to instead queue up all the --grep/--author/--committer options until the very end and _then_ compile them at the end, after you saw all the other grep related options such as -i/-F/-E

I am not interested in helping people with attitude very much ;-), but one somewhat related thing I have been wanting to add was the change in the attached patch. It allows you to anchor not just at the beginning but at the end.

 revision.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
diff --git c/revision.c w/revision.c
index 36291b6..83478ef 100644
--- c/revision.c
+++ w/revision.c
@@ -956,18 +956,24 @@ static void add_grep(struct rev_info *revs, const char *ptn, enum grep_pat_token
 static void add_header_grep(struct rev_info *revs, const char *field, const char *pattern)
 {
 	char *pat;
-	const char *prefix;
+	const char *prefix, *suffix;
 	int patlen, fldlen;
 
 	fldlen = strlen(field);
 	patlen = strlen(pattern);
-	pat = xmalloc(patlen + fldlen + 10);
-	prefix = ".*";
+	pat = xmalloc(patlen + fldlen + 64);
+	suffix = prefix = ".*";
 	if (*pattern == '^') {
 		prefix = "";
 		pattern++;
+		patlen--;
 	}
-	sprintf(pat, "^%s %s%s", field, prefix, pattern);
+	if (pattern[patlen-1] == '$') {
+		suffix = "";
+		patlen--;
+	}
+	sprintf(pat, "^%s %s%.*s%s [1-9][0-9]* [-+][0-1][0-9][0-9][0-9]$",
+		field, prefix, patlen, pattern, suffix);
 	add_grep(revs, pat, GREP_PATTERN_HEAD);
 }
 
Previous: Giuseppe BilottaNext: Junio C Hamano
Message 2 of 13 in “git rev-list --author/--committer b0rked with -F/--fixed-strings”
  1. Giuseppe BilottaSep 4, 2008
  2. Junio C HamanoSep 4, 2008
  3. Teach "log -F --author=<match>" to behave betterJunio C Hamano, Sep 4, 2008
  4. Teemu LikonenSep 4, 2008
  5. Junio C HamanoSep 4, 2008
  6. Teemu LikonenSep 4, 2008
  7. Junio C HamanoSep 5, 2008
  8. Giuseppe BilottaSep 4, 2008
  9. Petr BaudisSep 4, 2008
  10. Junio C HamanoSep 4, 2008
  11. --all-matchTeemu Likonen, Sep 5, 2008
  12. Junio C HamanoSep 5, 2008
  13. Giuseppe BilottaSep 4, 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.