Skip to content

Commit ffdfcab

Browse files
ilya-bobyrgitster
authored andcommitted
diff: docs: Use --patch-{grep,modifies} over -G/-S
Long argument names are easier to read, compared to short ones. So while short arguments are great when you want to type a command quickly, the documentation readability is improved if we use long argument names. Note for reviewers: All changes are just a replacement of `-G` with `--patch-grep` and `-S` with `--patch-modifies`. But as the text was reformatted to fit the same width in a few places it might look like there are more changes, if the diff is only line-wise and not word-wise. The only an exception are changes in `gitdiffcore.adoc`, where I did rephrase a sentence. I've moved introduction of the short versions of the `--patch-{grep,modifies}` into a subsequent paragraph. The reason is that I wanted to keep a note on the `-G` mnemonic, and it was awkward if I would repeat the short definition twice over a span of two paragraphs. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 80b0909 commit ffdfcab

File tree

3 files changed

+46
-45
lines changed

3 files changed

+46
-45
lines changed

Documentation/diff-options.txt

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -658,8 +658,8 @@ renamed entries cannot appear if detection for those types is disabled.
658658
It is useful when you're looking for an exact block of code (like a
659659
struct), and want to know the history of that block since it first
660660
came into being: use the feature iteratively to feed the interesting
661-
block in the preimage back into `-S`, and keep going until you get the
662-
very first version of the block.
661+
block in the preimage back into `--patch-modifies`, and keep going until
662+
you get the very first version of the block.
663663
+
664664
Binary files are searched as well.
665665

@@ -668,19 +668,19 @@ Binary files are searched as well.
668668
Look for differences whose patch text contains added/removed
669669
lines that match _<regex>_.
670670
+
671-
To illustrate the difference between `-S<regex>` `--pickaxe-regex` and
672-
`-G<regex>`, consider a commit with the following diff in the same
673-
file:
671+
To illustrate the difference between `--patch-modifies=<regex>
672+
--pickaxe-regex` and `--patch-grep=<regex>`, consider a commit with the
673+
following diff in the same file:
674674
+
675675
----
676676
+ return frotz(nitfol, two->ptr, 1, 0);
677677
...
678678
- hit = frotz(nitfol, mf2.ptr, 1, 0);
679679
----
680680
+
681-
While `git log -G"frotz\(nitfol"` will show this commit, `git log
682-
-S"frotz\(nitfol" --pickaxe-regex` will not (because the number of
683-
occurrences of that string did not change).
681+
While `git log --patch-grep="frotz\(nitfol"` will show this commit, `git
682+
log --patch-modifies="frotz\(nitfol" --pickaxe-regex` will not (because the
683+
number of occurrences of that string did not change).
684684
+
685685
Unless `--text` is supplied patches of binary files without a textconv
686686
filter will be ignored.
@@ -689,22 +689,22 @@ See the 'pickaxe' entry in linkgit:gitdiffcore[7] for more
689689
information.
690690

691691
`--find-object=<object-id>`::
692-
Look for differences that change the number of occurrences of
693-
the specified object. Similar to `-S`, just the argument is different
694-
in that it doesn't search for a specific string but for a specific
695-
object id.
692+
Look for differences that change the number of occurrences of the
693+
specified object. Similar to `--patch-modifies`, just the argument
694+
is different in that it doesn't search for a specific string but
695+
for a specific object id.
696696
+
697697
The object can be a blob or a submodule commit. It implies the `-t` option in
698698
`git-log` to also find trees.
699699

700700
`--pickaxe-all`::
701-
When `-S` or `-G` finds a change, show all the changes in that
702-
changeset, not just the files that contain the change
703-
in _<string>_.
701+
When `--patch-modifies` or `--patch-grep` finds a change, show all
702+
the changes in that changeset, not just the files that contain the
703+
change in _<string>_.
704704

705705
`--pickaxe-regex`::
706-
Treat the _<string>_ given to `-S` as an extended POSIX regular
707-
expression to match.
706+
Treat the _<string>_ given to `--patch-modifies` as an extended
707+
POSIX regular expression to match.
708708

709709
endif::git-format-patch[]
710710

Documentation/git-blame.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ a text string in the diff. A small example of the pickaxe interface
4141
that searches for `blame_usage`:
4242

4343
-----------------------------------------------------------------------------
44-
$ git log --pretty=oneline -S'blame_usage'
44+
$ git log --pretty=oneline --patch-modifies='blame_usage'
4545
5040f17eba15504bad66b14a645bddd9b015ebb7 blame -S <ancestry-file>
4646
ea4c7f9bf69e781dd0cd88d2bccb2bf5cc15c9a7 git-blame: Make the output
4747
-----------------------------------------------------------------------------

Documentation/gitdiffcore.txt

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -245,33 +245,34 @@ diffcore-pickaxe: For Detecting Addition/Deletion of Specified String
245245

246246
This transformation limits the set of filepairs to those that change
247247
specified strings between the preimage and the postimage in a certain
248-
way. `--patch-modifies=<string>` (`-S<string>` for short) and
249-
`--patch-grep=<regex>` (`-G<regex>` for short) are used to specify
250-
different ways these strings are sought.
251-
252-
`-S<string>` detects filepairs whose preimage and postimage
253-
have different number of occurrences of the specified _<string>_.
254-
By definition, it will not detect in-file moves. Also, when a
255-
changeset moves a file wholesale without affecting the interesting
256-
string, diffcore-rename kicks in as usual, and `-S` omits the filepair
257-
(since the number of occurrences of that string didn't change in that
258-
rename-detected filepair). When used with `--pickaxe-regex`, treat
259-
the _<string>_ as an extended POSIX regular expression to match,
260-
instead of a literal string.
261-
262-
`-G<regex>` (mnemonic: grep) detects filepairs whose textual diff has
263-
an added or a deleted line that matches the given _<regex>_. This
264-
means that it will detect in-file (or what rename-detection considers
265-
the same file) moves, which is noise. The implementation runs diff
266-
twice and greps, and this can be quite expensive. To speed things up,
267-
binary files without textconv filters will be ignored.
268-
269-
When `-S` or `-G` are used without `--pickaxe-all`, only filepairs
270-
that match their respective criterion are kept in the output. When
271-
`--pickaxe-all` is used, if even one filepair matches their respective
272-
criterion in a changeset, the entire changeset is kept. This behavior
273-
is designed to make reviewing changes in the context of the whole
274-
changeset easier.
248+
way. `--patch-modifies=<string>` and `--patch-grep=<regex>` are used
249+
to specify different ways these strings are sought.
250+
251+
`--patch-modifies=<string>` (`-S<string>` for short) detects filepairs
252+
whose preimage and postimage have different number of occurrences of
253+
the specified _<string>_. By definition, it will not detect in-file
254+
moves. Also, when a changeset moves a file wholesale without
255+
affecting the interesting string, diffcore-rename kicks in as usual,
256+
and `--patch-modifies` omits the filepair (since the number of
257+
occurrences of that string didn't change in that rename-detected
258+
filepair). When used with `--pickaxe-regex`, treat the _<string>_ as
259+
an extended POSIX regular expression to match, instead of a literal
260+
string.
261+
262+
`--patch-grep=<regex>` (`-G<regex>` for short, mnemonic: grep) detects
263+
filepairs whose textual diff has an added or a deleted line that
264+
matches the given regular expression. This means that it will detect
265+
in-file (or what rename-detection considers the same file) moves,
266+
which is noise. The implementation runs diff twice and greps, and
267+
this can be quite expensive. To speed things up, binary files without
268+
textconv filters will be ignored.
269+
270+
When `--patch-modifies` or `--patch-grep` are used without
271+
`--pickaxe-all`, only filepairs that match their respective criterion
272+
are kept in the output. When `--pickaxe-all` is used, if even one
273+
filepair matches their respective criterion in a changeset, the entire
274+
changeset is kept. This behavior is designed to make reviewing
275+
changes in the context of the whole changeset easier.
275276

276277
diffcore-order: For Sorting the Output Based on Filenames
277278
---------------------------------------------------------

0 commit comments

Comments
 (0)