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

Re: [PATCH] Added 'git-rev-list --igrep' option for case insensitive grep

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 22, 2007, 06:17 UTC
Message-ID
<7vwswtrmhe.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7v8x99t25s.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <gitster@pobox.com> writes:
Show 5 quoted lines
> Are there notable side effects you would need to warn users
> about?
>
> For example, what is the difference between "--igrep=foo
> --author=bar" and "--grep=foo --author=bar"?
Nah, let's not try to be too subtle.  It does not work.

What I am wondering is if there is an unintended option name conflict if we simply accept "-i" and "-E" as synonyms to "--regexp-ignore-case" and "--extended-regexp". The option parser for log family in revision.c is used from many places, so it is a bit hard to verify everobody to be absolutely sure, but I do not think of any offhand. There indeed are commands that take "-i" to mean something other than ignore-case, but ignore-case would not be meaningful for their operation.

So I would rather prefer this replacement patch.
-- >8 --
Synonyms: -i == --regexp-ignore-case, -E == --extended-regexp

These options to log family were too long to type. Give them shorter synonyms.

Fix the parsing of the long options while at it.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Documentation/git-rev-list.txt |    7 ++++---
 revision.c                     |    6 ++++--
 2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt
index 08e7573..f9fadaf 100644
--- a/Documentation/git-rev-list.txt
+++ b/Documentation/git-rev-list.txt
@@ -27,7 +27,8 @@ SYNOPSIS
 	     [ \--cherry-pick ]
 	     [ \--encoding[=<encoding>] ]
 	     [ \--(author|committer|grep)=<pattern> ]
-	     [ \--regexp-ignore-case ] [ \--extended-regexp ]
+	     [ \--regexp-ignore-case | \-i ]
+	     [ \--extended-regexp | \-E ]
 	     [ \--date={local|relative|default|iso|rfc|short} ]
 	     [ [\--objects | \--objects-edge] [ \--unpacked ] ]
 	     [ \--pretty | \--header ]
@@ -227,11 +228,11 @@ limiting may be applied.
 	Limit the commits output to ones with log message that
 	matches the specified pattern (regular expression).
 
---regexp-ignore-case::
+--regexp-ignore-case, -i::
 
 	Match the regexp limiting patterns without regard to letters case.
 
---extended-regexp::
+--extended-regexp, -E::
 
 	Consider the limiting patterns to be extended regular expressions
 	instead of the default basic regular expressions.
diff --git a/revision.c b/revision.c
index 7036cf2..00b75bc 100644
--- a/revision.c
+++ b/revision.c
@@ -1165,11 +1165,13 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
 				add_message_grep(revs, arg+7);
 				continue;
 			}
-			if (!prefixcmp(arg, "--extended-regexp")) {
+			if (!strcmp(arg, "--extended-regexp") ||
+			    !strcmp(arg, "-E")) {
 				regflags |= REG_EXTENDED;
 				continue;
 			}
-			if (!prefixcmp(arg, "--regexp-ignore-case")) {
+			if (!strcmp(arg, "--regexp-ignore-case") ||
+			    !strcmp(arg, "-i")) {
 				regflags |= REG_ICASE;
 				continue;
 			}
Previous: Junio C HamanoNext: Dmitry Kakurin
Message 3 of 4 in “Added 'git-rev-list --igrep' option for case insensitive grep”
  1. Added 'git-rev-list --igrep' option for case insensitive grepDmitry Kakurin, Jul 22, 2007
  2. Junio C HamanoJul 22, 2007
  3. Junio C HamanoJul 22, 2007
  4. Dmitry KakurinJul 22, 2007

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.