git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Added 'git-rev-list --igrep' option for case insensitive grep
@ 2007-07-22  5:33 Dmitry Kakurin
  2007-07-22  5:53 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Kakurin @ 2007-07-22  5:33 UTC (permalink / raw)
  To: git

>From 4b16e1823875f0051e3f0590803ab67dd3ca341d Mon Sep 17 00:00:00 2001
From: Dmitry Kakurin <Dmitry.Kakurin@gmail.com>
Date: Sat, 21 Jul 2007 22:22:49 -0700
Subject: [PATCH] Added 'git-rev-list --igrep' option for case insensitive grep

---
 Documentation/git-rev-list.txt |    6 +++++-
 revision.c                     |    5 +++++
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt
index 08e7573..f427862 100644
--- a/Documentation/git-rev-list.txt
+++ b/Documentation/git-rev-list.txt
@@ -26,7 +26,7 @@ SYNOPSIS
 	     [ \--left-right ]
 	     [ \--cherry-pick ]
 	     [ \--encoding[=<encoding>] ]
-	     [ \--(author|committer|grep)=<pattern> ]
+	     [ \--(author|committer|grep|igrep)=<pattern> ]
 	     [ \--regexp-ignore-case ] [ \--extended-regexp ]
 	     [ \--date={local|relative|default|iso|rfc|short} ]
 	     [ [\--objects | \--objects-edge] [ \--unpacked ] ]
@@ -227,6 +227,10 @@ limiting may be applied.
 	Limit the commits output to ones with log message that
 	matches the specified pattern (regular expression).

+--igrep='pattern'::
+
+	Equivalent to --grep='pattern' --regexp-ignore-case.
+
 --regexp-ignore-case::

 	Match the regexp limiting patterns without regard to letters case.
diff --git a/revision.c b/revision.c
index 28b5f2e..d5e1e69 100644
--- a/revision.c
+++ b/revision.c
@@ -1165,6 +1165,11 @@ int setup_revisions(int argc, const char
**argv, struct rev_info *revs, const ch
 				add_message_grep(revs, arg+7);
 				continue;
 			}
+			if (!prefixcmp(arg, "--igrep=")) {
+				add_message_grep(revs, arg+8);
+				regflags |= REG_ICASE;
+				continue;
+			}
 			if (!prefixcmp(arg, "--extended-regexp")) {
 				regflags |= REG_EXTENDED;
 				continue;
-- 
1.5.2.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Added 'git-rev-list --igrep' option for case insensitive grep
  2007-07-22  5:33 [PATCH] Added 'git-rev-list --igrep' option for case insensitive grep Dmitry Kakurin
@ 2007-07-22  5:53 ` Junio C Hamano
  2007-07-22  6:17   ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2007-07-22  5:53 UTC (permalink / raw)
  To: Dmitry Kakurin; +Cc: git

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"?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Added 'git-rev-list --igrep' option for case insensitive grep
  2007-07-22  5:53 ` Junio C Hamano
@ 2007-07-22  6:17   ` Junio C Hamano
  2007-07-22  7:52     ` Dmitry Kakurin
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2007-07-22  6:17 UTC (permalink / raw)
  To: Dmitry Kakurin; +Cc: git

Junio C Hamano <gitster@pobox.com> writes:

> 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;
 			}

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Added 'git-rev-list --igrep' option for case insensitive grep
  2007-07-22  6:17   ` Junio C Hamano
@ 2007-07-22  7:52     ` Dmitry Kakurin
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Kakurin @ 2007-07-22  7:52 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Sounds good to me.
Let's just put short option names in front of long names in the doc to
be consistent with other sections.

On 7/21/07, Junio C Hamano <gitster@pobox.com> wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
> > 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;
>                         }
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-07-22  7:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-22  5:33 [PATCH] Added 'git-rev-list --igrep' option for case insensitive grep Dmitry Kakurin
2007-07-22  5:53 ` Junio C Hamano
2007-07-22  6:17   ` Junio C Hamano
2007-07-22  7:52     ` Dmitry Kakurin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).