From: Junio C Hamano <gitster@pobox.com>
To: Michael J Gruber <git@drmicha.warpmail.net>
Cc: Tim Friske <me@tifr.de>, git <git@vger.kernel.org>
Subject: Re: Why does "git log -G<regex>" works with "regexp-ignore-case" but not with other regexp-related options?
Date: Fri, 17 Apr 2015 10:09:54 -0700 [thread overview]
Message-ID: <xmqq7ftaheal.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <55311831.6010004@drmicha.warpmail.net> (Michael J. Gruber's message of "Fri, 17 Apr 2015 16:26:57 +0200")
Michael J Gruber <git@drmicha.warpmail.net> writes:
>> Similarly I think it is not very consistent that one cannot combine any of
>> the above options with the "S<string>" but instead have yet another option
>> called "pickaxe-regex" to toggle between "fixed-string" and
>> "extended-regexp" semantics for the argument passed to option "S".
>
> The defaults are different, and it is likely that users want to switch
> one without switching the other.
>
> E.g., with -S you often use strings that you'd rather not have to quote
> to guard them against the regexp engine.
But the hypothetical -G that would look for a fixed string would be
vastly different from -S, wouldn't it?
The -S<string> option was invented to find a commit where one side
of the comparison has that string in the blob and the other side
does not; it shows commits where <string> appears different number
of times in the before- and the after- blobs, because doing so does
not hurt its primary use case to find commits where one side has one
instance of <string> and the other side has zero.
But -G<regexp> shows commits whose "git show $that_commit" output
would have lines matching <regexp> as added or deleted. So you get
different results from this history:
(before) (after)
a b
b a
c c
As "git show" for such a commit looks like this:
diff --git a/one b/one
index de98044..0c81c28 100644
--- a/one
+++ b/one
@@ -1,3 +1,3 @@
-a
b
+a
c
"git log -Ga" would say it is a match. But from "git log -Sa"'s
point of view, it is not a match; both sides have the same number of
'a' [*1*].
I think it would make sense to teach --fixed-strings or whatever
option to -G just like it pays attention to ignore-case, but "-G
--fixed-strings" cannot be "-S". They have different semantics.
[Footnote]
*1* This is because -S was envisioned as (and its behaviour has been
maintained as such) a building block for Porcelain that does
more than "git blame". You feed a _unique_ block of lines taken
from the current contents as the <string> to quickly find the
last commit that touched that area, and iteratively dig deeper.
The -S option was meant to be used for that single step of
digging, as a part of much more grand vision in $gmane/217,
which I would still consider one of the most important messages
on the mailing list, posted 10 years ago ;-)
next prev parent reply other threads:[~2015-04-17 17:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-17 10:00 Why does "git log -G<regex>" works with "regexp-ignore-case" but not with other regexp-related options? Tim Friske
2015-04-17 14:26 ` Michael J Gruber
2015-04-17 16:18 ` Junio C Hamano
2015-04-17 17:09 ` Junio C Hamano [this message]
2015-04-17 17:45 ` Junio C Hamano
2015-04-20 8:49 ` Michael J Gruber
2015-04-20 17:41 ` Junio C Hamano
2015-04-20 18:33 ` Linus Torvalds
2015-04-20 18:44 ` Junio C Hamano
2015-04-21 8:41 ` Michael J Gruber
2015-04-21 16:59 ` Junio C Hamano
2015-04-22 9:08 ` Michael J Gruber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq7ftaheal.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=git@drmicha.warpmail.net \
--cc=git@vger.kernel.org \
--cc=me@tifr.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.