From: Ramkumar Ramachandra <artagnon@gmail.com>
To: Git List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] diffcore-pickaxe doc: document -S and -G properly
Date: Tue, 14 May 2013 19:42:39 +0530 [thread overview]
Message-ID: <1368540759-25598-1-git-send-email-artagnon@gmail.com> (raw)
The documentation of -S and -G is very sketchy. Completely rewrite the
sections in Documentation/diff-options.txt and
Documentation/gitdiffcore.txt.
References:
52e9578 ([PATCH] Introducing software archaeologist's tool "pickaxe".)
f506b8e (git log/diff: add -G<regexp> that greps in the patch text)
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
I spent some time reading the code and history to figure out what -S
and -G really do. I hope I've done justice.
Documentation/diff-options.txt | 35 +++++++++++++++++++++++++++-------
Documentation/gitdiffcore.txt | 43 +++++++++++++++++++++++-------------------
2 files changed, 52 insertions(+), 26 deletions(-)
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 104579d..765abc5 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -383,14 +383,35 @@ ifndef::git-format-patch[]
that matches other criteria, nothing is selected.
-S<string>::
- Look for differences that introduce or remove an instance of
- <string>. Note that this is different than the string simply
- appearing in diff output; see the 'pickaxe' entry in
- linkgit:gitdiffcore[7] for more details.
+ Look for commits where the specified string was added or
+ removed. More precisely, find commits that change the number
+ of occurrences of the specified string.
++
+It is often useful when you're looking for an exact string (like a
+function prototype), and want to know the history of that string since
+it first came into being.
-G<regex>::
- Look for differences whose added or removed line matches
- the given <regex>.
+ Grep through the patch text of commits for added/removed lines
+ that match <regex>. `--pickaxe-regex` is implied in this
+ mode.
++
+To illustrate the difference between `-S<regex> --pickaxe-regex` and
+`-G<regex>`, consider a commit with the following diff in the same
+file:
++
+----
++ return !regexec(regexp, two->ptr, 1, ®match, 0);
+...
+- hit = !regexec(regexp, mf2.ptr, 1, ®match, 0);
+----
++
+While `git log -G"regexec\(regexp"` will show this commit, `git log
+-S"regexec\(regexp" --pickaxe-regex` will not (because the number of
+occurrences of that string didn't change).
++
+See the 'pickaxe' entry in linkgit:gitdiffcore[7] for more
+information.
--pickaxe-all::
When `-S` or `-G` finds a change, show all the changes in that
@@ -399,7 +420,7 @@ ifndef::git-format-patch[]
--pickaxe-regex::
Make the <string> not a plain string but an extended POSIX
- regex to match.
+ regex to match. Implied when using `-G`.
endif::git-format-patch[]
-O<orderfile>::
diff --git a/Documentation/gitdiffcore.txt b/Documentation/gitdiffcore.txt
index 568d757..39b9c51 100644
--- a/Documentation/gitdiffcore.txt
+++ b/Documentation/gitdiffcore.txt
@@ -222,25 +222,30 @@ version prefixed with '+'.
diffcore-pickaxe: For Detecting Addition/Deletion of Specified String
---------------------------------------------------------------------
-This transformation is used to find filepairs that represent
-changes that touch a specified string, and is controlled by the
--S option and the `--pickaxe-all` option to the 'git diff-*'
-commands.
-
-When diffcore-pickaxe is in use, it checks if there are
-filepairs whose "result" side and whose "origin" side have
-different number of specified string. Such a filepair represents
-"the string appeared in this changeset". It also checks for the
-opposite case that loses the specified string.
-
-When `--pickaxe-all` is not in effect, diffcore-pickaxe leaves
-only such filepairs that touch the specified string in its
-output. When `--pickaxe-all` is used, diffcore-pickaxe leaves all
-filepairs intact if there is such a filepair, or makes the
-output empty otherwise. The latter behaviour is designed to
-make reviewing of the changes in the context of the whole
-changeset easier.
-
+There are two kinds of pickaxe: the S kind (corresponding to 'git log
+-S') and the G kind (corresponding to 'git log -G').
+
+The S kind detects filepairs whose "result" side and "origin" side
+have different number of occurrences of specified string. While
+rename detection works as usual, 'git log -S' cannot omit commits
+where a the small string being looked for is moved verbatim from one
+file to another (since the number of occurrences of that string
+changed in each of those two filepairs). The implementation
+essentially runs a count, and is significantly cheaper than the G
+kind.
+
+The G kind detects filepairs whose patch text has an added or a
+deleted line that matches the given regexp. This means that it can
+detect in-file (or what rename-detection considers the same file)
+moves. The implementation of 'git log -G' runs diff twice and greps,
+and this can be quite expensive.
+
+A diffcore-pickaxe option worth mentioning: `--pickaxe-all`. When not
+in effect, diffcore-pickaxe leaves only such filepairs that touch the
+specified string in its output. When in effect, diffcore-pickaxe
+leaves all filepairs intact if there is such a filepair, or makes the
+output empty otherwise. The latter behavior is designed to make
+reviewing of the changes in the context of the whole changeset easier.
diffcore-order: For Sorting the Output Based on Filenames
---------------------------------------------------------
--
1.8.3.rc1.61.g2cacfff
next reply other threads:[~2013-05-14 14:11 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-14 14:12 Ramkumar Ramachandra [this message]
2013-05-14 17:41 ` [PATCH] diffcore-pickaxe doc: document -S and -G properly Junio C Hamano
2013-05-14 18:20 ` Ramkumar Ramachandra
2013-05-14 18:47 ` Junio C Hamano
2013-05-14 18:57 ` Ramkumar Ramachandra
2013-05-14 19:17 ` Jonathan Nieder
2013-05-14 19:25 ` Ramkumar Ramachandra
2013-05-14 19:29 ` Jonathan Nieder
2013-05-14 19:41 ` Junio C Hamano
2013-05-14 19:31 ` Junio C Hamano
2013-05-14 21:13 ` Phil Hord
2013-05-14 17:44 ` Phil Hord
2013-05-14 17:47 ` Phil Hord
2013-05-14 18:44 ` Ramkumar Ramachandra
2013-05-14 19:19 ` Junio C Hamano
2013-05-14 19:46 ` Ramkumar Ramachandra
2013-05-14 19:53 ` Junio C Hamano
2013-05-14 20:02 ` Ramkumar Ramachandra
2013-05-14 19:23 ` Phil Hord
2013-05-14 18:57 ` Junio C Hamano
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=1368540759-25598-1-git-send-email-artagnon@gmail.com \
--to=artagnon@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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 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).