* Supporting "-v" option for git-log
@ 2011-05-25 9:40 Elazar Leibovich
2011-05-25 11:05 ` Tim Mazid
0 siblings, 1 reply; 14+ messages in thread
From: Elazar Leibovich @ 2011-05-25 9:40 UTC (permalink / raw)
To: git
I want to use git log to show all commits that do not match a given
pattern. I know I can use the following to show all commits that do
match a pattern, similar to the "grep -v" command line option:
git log -v --grep=<pattern> # results all commits that do NOT match pattern
Is there a way invert the sense of matching?
If not, is it OK to submit a patch? Anything to consider for this patch?
[*] x-post from here
http://stackoverflow.com/questions/5602204/how-to-invert-git-log-grep-pattern-or-how-to-show-git-logs-that-dont-match
^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: Supporting "-v" option for git-log
2011-05-25 9:40 Supporting "-v" option for git-log Elazar Leibovich
@ 2011-05-25 11:05 ` Tim Mazid
2011-05-25 11:14 ` Elazar Leibovich
0 siblings, 1 reply; 14+ messages in thread
From: Tim Mazid @ 2011-05-25 11:05 UTC (permalink / raw)
To: elazarl, Git Mailing List
> Date: Wed, 25 May 2011 12:40:48 +0300
> From: elazarl@gmail.com
>
> I want to use git log to show all commits that do not match a given
> pattern. I know I can use the following to show all commits that do
> match a pattern, similar to the "grep -v" command line option:
>
> git log -v --grep= # results all commits that do NOT match pattern
>
> Is there a way invert the sense of matching?
>
> If not, is it OK to submit a patch? Anything to consider for this patch?
I'm confused; do you want to find all the commits that do not match a
pattern? Because you seem to have achieved that. If, on the other hand,
you want the commits that DO match a pattern, then just leave out the
"-v" option.
What exactly are you trying to achieve?
Tim.
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Supporting "-v" option for git-log
2011-05-25 11:05 ` Tim Mazid
@ 2011-05-25 11:14 ` Elazar Leibovich
2011-05-25 11:21 ` Tim Mazid
0 siblings, 1 reply; 14+ messages in thread
From: Elazar Leibovich @ 2011-05-25 11:14 UTC (permalink / raw)
To: Tim Mazid; +Cc: Git Mailing List
On Wed, May 25, 2011 at 2:05 PM, Tim Mazid <timmazid@hotmail.com> wrote:
>
>> Date: Wed, 25 May 2011 12:40:48 +0300
>> From: elazarl@gmail.com
>> git log -v --grep= # results all commits that do NOT match pattern
>>
>> Is there a way invert the sense of matching?
>>
> I'm confused; do you want to find all the commits that do not match a
> pattern? Because you seem to have achieved that. If, on the other hand,
> you want the commits that DO match a pattern, then just leave out the
> "-v" option.
>
> What exactly are you trying to achieve?
Oops, let me be 100% clear about that, "git log -v
--grep==<pattern_not_to_match" is NOT WORKING currently. I just
presented a possible syntax.
$ git --version
git version 1.7.4.msysgit.0
$ git log -v --grep=Normalized
commit 88c7a82aaf240ed130c64c455c294e7af04d30f8
Author: Elazar <elazarl@gmail.com>
Date: Mon May 16 10:40:21 2011 +0300
Normalized Makfile so that it'll work by default. Include Makefile
see, it ignores the "-v", and include only commits with "Normalized" -
the ones I don't want to see.
^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: Supporting "-v" option for git-log
2011-05-25 11:14 ` Elazar Leibovich
@ 2011-05-25 11:21 ` Tim Mazid
2011-05-25 11:24 ` Tim Mazid
2011-05-25 11:28 ` Elazar Leibovich
0 siblings, 2 replies; 14+ messages in thread
From: Tim Mazid @ 2011-05-25 11:21 UTC (permalink / raw)
To: elazarl; +Cc: Git Mailing List
> From: elazarl@gmail.com
> Oops, let me be 100% clear about that, "git log -v
> --grep==> presented a possible syntax.
>
> $ git --version
> git version 1.7.4.msysgit.0
> $ git log -v --grep=Normalized
> commit 88c7a82aaf240ed130c64c455c294e7af04d30f8
> Author: Elazar
> Date: Mon May 16 10:40:21 2011 +0300
>
> Normalized Makfile so that it'll work by default. Include Makefile
>
> see, it ignores the "-v", and include only commits with "Normalized" -
> the ones I don't want to see.
Ah, I see; my apologies.
Well, personally, I've never used the --grep option. I pipe it through
grep, where I can supply options such as -v. However, if the --grep
option already exists, then it does make sense to allow users to use
options they would normally be able to with grep.
As for the syntax, that seems like a good idea on the surface, but
how would you go about supporting other grep options? Such as
"-i"?
Tim.
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments
^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: Supporting "-v" option for git-log
2011-05-25 11:21 ` Tim Mazid
@ 2011-05-25 11:24 ` Tim Mazid
2011-05-25 11:28 ` Elazar Leibovich
1 sibling, 0 replies; 14+ messages in thread
From: Tim Mazid @ 2011-05-25 11:24 UTC (permalink / raw)
To: elazarl; +Cc: Git Mailing List
> From: timmazid@hotmail.com
> > From: elazarl@gmail.com
> > Oops, let me be 100% clear about that, "git log -v
> > --grep==> presented a possible syntax.
> >
> > $ git --version
> > git version 1.7.4.msysgit.0
> > $ git log -v --grep=Normalized
> > commit 88c7a82aaf240ed130c64c455c294e7af04d30f8
> > Author: Elazar
> > Date: Mon May 16 10:40:21 2011 +0300
> >
> > Normalized Makfile so that it'll work by default. Include Makefile
> >
> > see, it ignores the "-v", and include only commits with "Normalized" -
> > the ones I don't want to see.
>
> Ah, I see; my apologies.
>
> Well, personally, I've never used the --grep option. I pipe it through
> grep, where I can supply options such as -v. However, if the --grep
> option already exists, then it does make sense to allow users to use
> options they would normally be able to with grep.
>
> As for the syntax, that seems like a good idea on the surface, but
> how would you go about supporting other grep options? Such as
> "-i"?
Woops; my bad; "-i" is already supported. But the point still stands...
I think?
Should there be a seperate "--grep-options" option for "git log" to
pass options onto grep?
Tim.
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Supporting "-v" option for git-log
2011-05-25 11:21 ` Tim Mazid
2011-05-25 11:24 ` Tim Mazid
@ 2011-05-25 11:28 ` Elazar Leibovich
2011-05-25 11:35 ` Tim Mazid
2011-05-25 13:29 ` Jeff King
1 sibling, 2 replies; 14+ messages in thread
From: Elazar Leibovich @ 2011-05-25 11:28 UTC (permalink / raw)
To: Tim Mazid; +Cc: Git Mailing List
On Wed, May 25, 2011 at 2:21 PM, Tim Mazid <timmazid@hotmail.com> wrote:
>
> Well, personally, I've never used the --grep option. I pipe it through
> grep, where I can supply options such as -v.
But then you must use single-line commits output. Which is
inconvenient if you want to read all the commit message.
> However, if the --grep
> option already exists, then it does make sense to allow users to use
> options they would normally be able to with grep.
>
> As for the syntax, that seems like a good idea on the surface, but
> how would you go about supporting other grep options? Such as
> "-i"?
Now that I think of it, we already have the '--not' option for
revision specifiers. Why won't we use it for grep patterns? That way
-v will not be overloaded (it usually means verbose). For example
git log --all --not --grep A --grep B
Would mean find all commits without A and with B, in SQL "SELECT *
FROM COMMITS WHERE message NOT LIKE '%A%' AND message LIKE '%B%'".
^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: Supporting "-v" option for git-log
2011-05-25 11:28 ` Elazar Leibovich
@ 2011-05-25 11:35 ` Tim Mazid
2011-05-25 11:40 ` Elazar Leibovich
2011-05-25 13:29 ` Jeff King
1 sibling, 1 reply; 14+ messages in thread
From: Tim Mazid @ 2011-05-25 11:35 UTC (permalink / raw)
To: elazarl; +Cc: Git Mailing List
> Date: Wed, 25 May 2011 14:28:12 +0300
> From: elazarl@gmail.com
> On Wed, May 25, 2011 at 2:21 PM, Tim Mazid wrote:
> >
> > Well, personally, I've never used the --grep option. I pipe it through
> > grep, where I can supply options such as -v.
>
> But then you must use single-line commits output. Which is
> inconvenient if you want to read all the commit message.
That is a good point.
> > As for the syntax, that seems like a good idea on the surface, but
> > how would you go about supporting other grep options? Such as
> > "-i"?
>
> Now that I think of it, we already have the '--not' option for
> revision specifiers. Why won't we use it for grep patterns? That way
> -v will not be overloaded (it usually means verbose). For example
>
> git log --all --not --grep A --grep B
>
> Would mean find all commits without A and with B, in SQL "SELECT *
> FROM COMMITS WHERE message NOT LIKE '%A%' AND message LIKE '%B%'".
But how do you know which "--grep" the "--not" applies to? Does it have
to go directly before the "--grep" option? Can it be a few options before
as long is it's still before? If you want to find commits not matching two
patterns, do you have to do "--not --grep A --not --grep B"?
I can see this as being a possible source of confusion; people doing
"--not grep A --grep B" and expecting it to mean NOT A AND NOT B.
Tim.
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Supporting "-v" option for git-log
2011-05-25 11:35 ` Tim Mazid
@ 2011-05-25 11:40 ` Elazar Leibovich
0 siblings, 0 replies; 14+ messages in thread
From: Elazar Leibovich @ 2011-05-25 11:40 UTC (permalink / raw)
To: Tim Mazid; +Cc: Git Mailing List
On Wed, May 25, 2011 at 2:35 PM, Tim Mazid <timmazid@hotmail.com> wrote:
>
>> git log --all --not --grep A --grep B
>>
>> Would mean find all commits without A and with B, in SQL "SELECT *
>> FROM COMMITS WHERE message NOT LIKE '%A%' AND message LIKE '%B%'".
>
> But how do you know which "--grep" the "--not" applies to? Does it have
> to go directly before the "--grep" option?
Exactly, just like the ! operator in C.
> Can it be a few options before
> as long is it's still before?
No, only directly before the --grep, like the ! operator.
> If you want to find commits not matching two
> patterns, do you have to do "--not --grep A --not --grep B"?
Yes, we can add a --negate-all option if you think it's usefull.
>
> I can see this as being a possible source of confusion; people doing
> "--not grep A --grep B" and expecting it to mean NOT A AND NOT B.
You can add another option --negate which negates everything. But this
is a price to pay for being extra expressive.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Supporting "-v" option for git-log
2011-05-25 11:28 ` Elazar Leibovich
2011-05-25 11:35 ` Tim Mazid
@ 2011-05-25 13:29 ` Jeff King
2011-05-25 13:53 ` Jakub Narebski
2011-05-25 17:32 ` Junio C Hamano
1 sibling, 2 replies; 14+ messages in thread
From: Jeff King @ 2011-05-25 13:29 UTC (permalink / raw)
To: Elazar Leibovich; +Cc: Tim Mazid, Git Mailing List
On Wed, May 25, 2011 at 02:28:12PM +0300, Elazar Leibovich wrote:
> On Wed, May 25, 2011 at 2:21 PM, Tim Mazid <timmazid@hotmail.com> wrote:
> >
> > Well, personally, I've never used the --grep option. I pipe it through
> > grep, where I can supply options such as -v.
>
> But then you must use single-line commits output. Which is
> inconvenient if you want to read all the commit message.
You can use perl to consider records larger than a single line, like:
git log -z | perl -ln0e 'print unless /your pattern/'
But of course that is somewhat inconvenient to type, and is somewhat
slower than the internal grep.
> Now that I think of it, we already have the '--not' option for
> revision specifiers. Why won't we use it for grep patterns? That way
> -v will not be overloaded (it usually means verbose). For example
>
> git log --all --not --grep A --grep B
The problem is that "--not" already has a meaning, and the scope of that
meaning is different than what you propose. That is, in this command:
git log a --not b c
The "--not" applies to both "b" and "c". So you are changing the meaning
of the existing:
git log a --not --grep b c
(which now means "grep for b, but do not include commits in c"). And
even if we wanted to do that, there is a parsing ambiguity. Does the
"--not" apply _just_ to the grep, or does it also include "not c"?
Which is a shame, because we already have all of the code for "--and",
"--or", and "--not" in git-grep. It is just a syntactic conflict. I
think you could get away with "--grep-and", "--grep-or", and
"--grep-not". They are obviously less nice to type, but there would be
not conflict.
-Peff
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Supporting "-v" option for git-log
2011-05-25 13:29 ` Jeff King
@ 2011-05-25 13:53 ` Jakub Narebski
2011-05-25 15:11 ` Jeff King
2011-05-25 17:32 ` Junio C Hamano
1 sibling, 1 reply; 14+ messages in thread
From: Jakub Narebski @ 2011-05-25 13:53 UTC (permalink / raw)
To: Jeff King; +Cc: Elazar Leibovich, Tim Mazid, Git Mailing List
Jeff King <peff@peff.net> writes:
> On Wed, May 25, 2011 at 02:28:12PM +0300, Elazar Leibovich wrote:
[...]
> > Now that I think of it, we already have the '--not' option for
> > revision specifiers. Why won't we use it for grep patterns? That way
> > -v will not be overloaded (it usually means verbose). For example
> >
> > git log --all --not --grep A --grep B
>
> The problem is that "--not" already has a meaning, and the scope of that
> meaning is different than what you propose. That is, in this command:
>
> git log a --not b c
>
> The "--not" applies to both "b" and "c". So you are changing the meaning
> of the existing:
>
> git log a --not --grep b c
>
> (which now means "grep for b, but do not include commits in c"). And
> even if we wanted to do that, there is a parsing ambiguity. Does the
> "--not" apply _just_ to the grep, or does it also include "not c"?
>
> Which is a shame, because we already have all of the code for "--and",
> "--or", and "--not" in git-grep. It is just a syntactic conflict. I
> think you could get away with "--grep-and", "--grep-or", and
> "--grep-not". They are obviously less nice to type, but there would be
> not conflict.
Hmmm... perhaps short -! could be alias for --grep-not (it is the only
that needs to be changed to avoid conflict, as there are no --or and
--and for rev-list).
--
Jakub Narebski
Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Supporting "-v" option for git-log
2011-05-25 13:53 ` Jakub Narebski
@ 2011-05-25 15:11 ` Jeff King
2011-05-25 16:38 ` Jakub Narebski
0 siblings, 1 reply; 14+ messages in thread
From: Jeff King @ 2011-05-25 15:11 UTC (permalink / raw)
To: Jakub Narebski; +Cc: Elazar Leibovich, Tim Mazid, Git Mailing List
On Wed, May 25, 2011 at 06:53:31AM -0700, Jakub Narebski wrote:
> > Which is a shame, because we already have all of the code for "--and",
> > "--or", and "--not" in git-grep. It is just a syntactic conflict. I
> > think you could get away with "--grep-and", "--grep-or", and
> > "--grep-not". They are obviously less nice to type, but there would be
> > not conflict.
>
> Hmmm... perhaps short -! could be alias for --grep-not (it is the only
> that needs to be changed to avoid conflict, as there are no --or and
> --and for rev-list).
Ick. I really hate using shell metacharacters that need quoting
(especially "!", which even gets expanded inside double-quotes). But as
long as it's an alias, I guess people who care can use --grep-not.
We could use unadorned "--or" and "--and", though we should perhaps stop
and think whether taking those basic operators will block future use
that matches the current "--not" more.
Right now, "git log a b" is what I would expect "git log a --or b" to
do. I guess "git log a --and b" would be "git log $(git merge-base a
b)". So maybe it is not worth reserving them for the future, since what
they would (probably) accomplish is easy to do now.
-Peff
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Supporting "-v" option for git-log
2011-05-25 15:11 ` Jeff King
@ 2011-05-25 16:38 ` Jakub Narebski
0 siblings, 0 replies; 14+ messages in thread
From: Jakub Narebski @ 2011-05-25 16:38 UTC (permalink / raw)
To: Jeff King; +Cc: Elazar Leibovich, Tim Mazid, Git Mailing List
Dnia środa 25. maja 2011 17:11, Jeff King napisał:
> On Wed, May 25, 2011 at 06:53:31AM -0700, Jakub Narebski wrote:
>
> > > Which is a shame, because we already have all of the code for "--and",
> > > "--or", and "--not" in git-grep. It is just a syntactic conflict. I
> > > think you could get away with "--grep-and", "--grep-or", and
> > > "--grep-not". They are obviously less nice to type, but there would be
> > > not conflict.
> >
> > Hmmm... perhaps short -! could be alias for --grep-not (it is the only
> > that needs to be changed to avoid conflict, as there are no --or and
> > --and for rev-list).
>
> Ick. I really hate using shell metacharacters that need quoting
> (especially "!", which even gets expanded inside double-quotes). But as
> long as it's an alias, I guess people who care can use --grep-not.
Yeah, I know. Nevertheless '!' is natural to mean 'not',
and `-\!` is still shorter than `--grep-not`.
--
Jakub Narebski
Poland
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Supporting "-v" option for git-log
2011-05-25 13:29 ` Jeff King
2011-05-25 13:53 ` Jakub Narebski
@ 2011-05-25 17:32 ` Junio C Hamano
2011-05-25 20:01 ` Jeff King
1 sibling, 1 reply; 14+ messages in thread
From: Junio C Hamano @ 2011-05-25 17:32 UTC (permalink / raw)
To: Jeff King; +Cc: Elazar Leibovich, Tim Mazid, Git Mailing List
Jeff King <peff@peff.net> writes:
> The problem is that "--not" already has a meaning, and the scope of that
> meaning is different than what you propose. That is, in this command:
>
> git log a --not b c
>
> The "--not" applies to both "b" and "c". So you are changing the meaning
> of the existing:
>
> git log a --not --grep b c
>
> (which now means "grep for b, but do not include commits in c"). And
> even if we wanted to do that, there is a parsing ambiguity. Does the
> "--not" apply _just_ to the grep, or does it also include "not c"?
>
> Which is a shame, because we already have all of the code for "--and",
> "--or", and "--not" in git-grep.
True, that has always been an accepted limitation.
You could add --grep="-e A --and --not -e B --all-match", split_cmdline()
and then give the result to append_grep_pattern(), or something like that,
but I do not think it is worth doing.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Supporting "-v" option for git-log
2011-05-25 17:32 ` Junio C Hamano
@ 2011-05-25 20:01 ` Jeff King
0 siblings, 0 replies; 14+ messages in thread
From: Jeff King @ 2011-05-25 20:01 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Elazar Leibovich, Tim Mazid, Git Mailing List
On Wed, May 25, 2011 at 10:32:41AM -0700, Junio C Hamano wrote:
> > (which now means "grep for b, but do not include commits in c"). And
> > even if we wanted to do that, there is a parsing ambiguity. Does the
> > "--not" apply _just_ to the grep, or does it also include "not c"?
> >
> > Which is a shame, because we already have all of the code for "--and",
> > "--or", and "--not" in git-grep.
>
> True, that has always been an accepted limitation.
>
> You could add --grep="-e A --and --not -e B --all-match", split_cmdline()
> and then give the result to append_grep_pattern(), or something like that,
> but I do not think it is worth doing.
Besides being ambiguous with current usage (e.g., grepping for something
starting with "-e"), I do not long for the quoting nightmare of:
git log --grep="-e 'something with spaces'
--and --not -e 'something with \"double quotes\"'
--and --not -e 'something with '\\''single quotes'\\''"
-Peff
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2011-05-25 20:01 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-25 9:40 Supporting "-v" option for git-log Elazar Leibovich
2011-05-25 11:05 ` Tim Mazid
2011-05-25 11:14 ` Elazar Leibovich
2011-05-25 11:21 ` Tim Mazid
2011-05-25 11:24 ` Tim Mazid
2011-05-25 11:28 ` Elazar Leibovich
2011-05-25 11:35 ` Tim Mazid
2011-05-25 11:40 ` Elazar Leibovich
2011-05-25 13:29 ` Jeff King
2011-05-25 13:53 ` Jakub Narebski
2011-05-25 15:11 ` Jeff King
2011-05-25 16:38 ` Jakub Narebski
2011-05-25 17:32 ` Junio C Hamano
2011-05-25 20:01 ` Jeff King
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).