diffcore-pickaxe doc: document -S and -G properly

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) Inputs-from: Phil Hord <phil.hord@gmail.com> Co-authored-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ramkumar Ramachandra committed May 31, 2013 at 17:42 UTC 5bc3f0b56779d189aaf7cab7e5d307aa4e7c0887
2 files changed +57 -26
Documentation/diff-options.txt
+30 -8
@@ -383,14 +383,36 @@ ifndef::git-format-patch[]
383 that matches other criteria, nothing is selected.
384
385 -S<string>::
386 - Look for differences that introduce or remove an instance of
387 - <string>. Note that this is different than the string simply
388 - appearing in diff output; see the 'pickaxe' entry in
389 - linkgit:gitdiffcore[7] for more details.
386 + Look for differences that change the number of occurrences of
387 + the specified string (i.e. addition/deletion) in a file.
388 + Intended for the scripter's use.
389 ++
390 +It is useful when you're looking for an exact block of code (like a
391 +struct), and want to know the history of that block since it first
392 +came into being: use the feature iteratively to feed the interesting
393 +block in the preimage back into `-S`, and keep going until you get the
394 +very first version of the block.
395
396 -G<regex>::
392 - Look for differences whose added or removed line matches
393 - the given <regex>.
397 + Look for differences whose patch text contains added/removed
398 + lines that match <regex>.
399 ++
400 +To illustrate the difference between `-S<regex> --pickaxe-regex` and
401 +`-G<regex>`, consider a commit with the following diff in the same
402 +file:
403 ++
404 +----
405 ++ return !regexec(regexp, two->ptr, 1, &regmatch, 0);
406 +...
407 +- hit = !regexec(regexp, mf2.ptr, 1, &regmatch, 0);
408 +----
409 ++
410 +While `git log -G"regexec\(regexp"` will show this commit, `git log
411 +-S"regexec\(regexp" --pickaxe-regex` will not (because the number of
412 +occurrences of that string did not change).
413 ++
414 +See the 'pickaxe' entry in linkgit:gitdiffcore[7] for more
415 +information.
416
417 --pickaxe-all::
418 When `-S` or `-G` finds a change, show all the changes in that
@@ -398,8 +420,8 @@ ifndef::git-format-patch[]
420 in <string>.
421
422 --pickaxe-regex::
401 - Make the <string> not a plain string but an extended POSIX
402 - regex to match.
423 + Treat the <string> given to `-S` as an extended POSIX regular
424 + expression to match.
425 endif::git-format-patch[]
426
427 -O<orderfile>::
Documentation/gitdiffcore.txt
+27 -18
@@ -222,26 +222,35 @@ version prefixed with '+'.
222 diffcore-pickaxe: For Detecting Addition/Deletion of Specified String
223 ---------------------------------------------------------------------
224
225 -This transformation is used to find filepairs that represent
226 -changes that touch a specified string, and is controlled by the
227 --S option and the `--pickaxe-all` option to the 'git diff-*'
228 -commands.
229 -
230 -When diffcore-pickaxe is in use, it checks if there are
231 -filepairs whose "result" side and whose "origin" side have
232 -different number of specified string. Such a filepair represents
233 -"the string appeared in this changeset". It also checks for the
234 -opposite case that loses the specified string.
235 -
236 -When `--pickaxe-all` is not in effect, diffcore-pickaxe leaves
237 -only such filepairs that touch the specified string in its
238 -output. When `--pickaxe-all` is used, diffcore-pickaxe leaves all
239 -filepairs intact if there is such a filepair, or makes the
240 -output empty otherwise. The latter behaviour is designed to
241 -make reviewing of the changes in the context of the whole
225 +This transformation limits the set of filepairs to those that change
226 +specified strings between the preimage and the postimage in a certain
227 +way. -S<block of text> and -G<regular expression> options are used to
228 +specify different ways these strings are sought.
229 +
230 +"-S<block of text>" detects filepairs whose preimage and postimage
231 +have different number of occurrences of the specified block of text.
232 +By definition, it will not detect in-file moves. Also, when a
233 +changeset moves a file wholesale without affecting the interesting
234 +string, diffcore-rename kicks in as usual, and `-S` omits the filepair
235 +(since the number of occurrences of that string didn't change in that
236 +rename-detected filepair). When used with `--pickaxe-regex`, treat
237 +the <block of text> as an extended POSIX regular expression to match,
238 +instead of a literal string.
239 +
240 +"-G<regular expression>" (mnemonic: grep) detects filepairs whose
241 +textual diff has an added or a deleted line that matches the given
242 +regular expression. This means that it will detect in-file (or what
243 +rename-detection considers the same file) moves, which is noise. The
244 +implementation runs diff twice and greps, and this can be quite
245 +expensive.
246 +
247 +When `-S` or `-G` are used without `--pickaxe-all`, only filepairs
248 +that match their respective criterion are kept in the output. When
249 +`--pickaxe-all` is used, if even one filepair matches their respective
250 +criterion in a changeset, the entire changeset is kept. This behavior
251 +is designed to make reviewing changes in the context of the whole
252 changeset easier.
253
244 -
254 diffcore-order: For Sorting the Output Based on Filenames
255 ---------------------------------------------------------
256