Merge branch 'rr/diffcore-pickaxe-doc'
Update the low-level diffcore documentation on -S/-G and --pickaxe-all. * rr/diffcore-pickaxe-doc: diffcore-pickaxe doc: document -S and -G properly diffcore-pickaxe: make error messages more consistent
This commit is contained in:
commit
71e120202f
@ -383,14 +383,36 @@ ifndef::git-format-patch[]
|
|||||||
that matches other criteria, nothing is selected.
|
that matches other criteria, nothing is selected.
|
||||||
|
|
||||||
-S<string>::
|
-S<string>::
|
||||||
Look for differences that introduce or remove an instance of
|
Look for differences that change the number of occurrences of
|
||||||
<string>. Note that this is different than the string simply
|
the specified string (i.e. addition/deletion) in a file.
|
||||||
appearing in diff output; see the 'pickaxe' entry in
|
Intended for the scripter's use.
|
||||||
linkgit:gitdiffcore[7] for more details.
|
+
|
||||||
|
It is useful when you're looking for an exact block of code (like a
|
||||||
|
struct), and want to know the history of that block since it first
|
||||||
|
came into being: use the feature iteratively to feed the interesting
|
||||||
|
block in the preimage back into `-S`, and keep going until you get the
|
||||||
|
very first version of the block.
|
||||||
|
|
||||||
-G<regex>::
|
-G<regex>::
|
||||||
Look for differences whose added or removed line matches
|
Look for differences whose patch text contains added/removed
|
||||||
the given <regex>.
|
lines that match <regex>.
|
||||||
|
+
|
||||||
|
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 did not change).
|
||||||
|
+
|
||||||
|
See the 'pickaxe' entry in linkgit:gitdiffcore[7] for more
|
||||||
|
information.
|
||||||
|
|
||||||
--pickaxe-all::
|
--pickaxe-all::
|
||||||
When `-S` or `-G` finds a change, show all the changes in that
|
When `-S` or `-G` finds a change, show all the changes in that
|
||||||
@ -398,8 +420,8 @@ ifndef::git-format-patch[]
|
|||||||
in <string>.
|
in <string>.
|
||||||
|
|
||||||
--pickaxe-regex::
|
--pickaxe-regex::
|
||||||
Make the <string> not a plain string but an extended POSIX
|
Treat the <string> given to `-S` as an extended POSIX regular
|
||||||
regex to match.
|
expression to match.
|
||||||
endif::git-format-patch[]
|
endif::git-format-patch[]
|
||||||
|
|
||||||
-O<orderfile>::
|
-O<orderfile>::
|
||||||
|
@ -222,26 +222,35 @@ version prefixed with '+'.
|
|||||||
diffcore-pickaxe: For Detecting Addition/Deletion of Specified String
|
diffcore-pickaxe: For Detecting Addition/Deletion of Specified String
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
This transformation is used to find filepairs that represent
|
This transformation limits the set of filepairs to those that change
|
||||||
changes that touch a specified string, and is controlled by the
|
specified strings between the preimage and the postimage in a certain
|
||||||
-S option and the `--pickaxe-all` option to the 'git diff-*'
|
way. -S<block of text> and -G<regular expression> options are used to
|
||||||
commands.
|
specify different ways these strings are sought.
|
||||||
|
|
||||||
When diffcore-pickaxe is in use, it checks if there are
|
"-S<block of text>" detects filepairs whose preimage and postimage
|
||||||
filepairs whose "result" side and whose "origin" side have
|
have different number of occurrences of the specified block of text.
|
||||||
different number of specified string. Such a filepair represents
|
By definition, it will not detect in-file moves. Also, when a
|
||||||
"the string appeared in this changeset". It also checks for the
|
changeset moves a file wholesale without affecting the interesting
|
||||||
opposite case that loses the specified string.
|
string, diffcore-rename kicks in as usual, and `-S` omits the filepair
|
||||||
|
(since the number of occurrences of that string didn't change in that
|
||||||
|
rename-detected filepair). When used with `--pickaxe-regex`, treat
|
||||||
|
the <block of text> as an extended POSIX regular expression to match,
|
||||||
|
instead of a literal string.
|
||||||
|
|
||||||
When `--pickaxe-all` is not in effect, diffcore-pickaxe leaves
|
"-G<regular expression>" (mnemonic: grep) detects filepairs whose
|
||||||
only such filepairs that touch the specified string in its
|
textual diff has an added or a deleted line that matches the given
|
||||||
output. When `--pickaxe-all` is used, diffcore-pickaxe leaves all
|
regular expression. This means that it will detect in-file (or what
|
||||||
filepairs intact if there is such a filepair, or makes the
|
rename-detection considers the same file) moves, which is noise. The
|
||||||
output empty otherwise. The latter behaviour is designed to
|
implementation runs diff twice and greps, and this can be quite
|
||||||
make reviewing of the changes in the context of the whole
|
expensive.
|
||||||
|
|
||||||
|
When `-S` or `-G` are used without `--pickaxe-all`, only filepairs
|
||||||
|
that match their respective criterion are kept in the output. When
|
||||||
|
`--pickaxe-all` is used, if even one filepair matches their respective
|
||||||
|
criterion in a changeset, the entire changeset is kept. This behavior
|
||||||
|
is designed to make reviewing changes in the context of the whole
|
||||||
changeset easier.
|
changeset easier.
|
||||||
|
|
||||||
|
|
||||||
diffcore-order: For Sorting the Output Based on Filenames
|
diffcore-order: For Sorting the Output Based on Filenames
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ static void diffcore_pickaxe_grep(struct diff_options *o)
|
|||||||
char errbuf[1024];
|
char errbuf[1024];
|
||||||
regerror(err, ®ex, errbuf, 1024);
|
regerror(err, ®ex, errbuf, 1024);
|
||||||
regfree(®ex);
|
regfree(®ex);
|
||||||
die("invalid log-grep regex: %s", errbuf);
|
die("invalid regex: %s", errbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
pickaxe(&diff_queued_diff, o, ®ex, NULL, diff_grep);
|
pickaxe(&diff_queued_diff, o, ®ex, NULL, diff_grep);
|
||||||
@ -246,7 +246,7 @@ static void diffcore_pickaxe_count(struct diff_options *o)
|
|||||||
char errbuf[1024];
|
char errbuf[1024];
|
||||||
regerror(err, ®ex, errbuf, 1024);
|
regerror(err, ®ex, errbuf, 1024);
|
||||||
regfree(®ex);
|
regfree(®ex);
|
||||||
die("invalid pickaxe regex: %s", errbuf);
|
die("invalid regex: %s", errbuf);
|
||||||
}
|
}
|
||||||
regexp = ®ex;
|
regexp = ®ex;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user