Home Explore Blog CI



git

5th chunk of `Documentation/gitdiffcore.adoc`
419288cecbf8761826685c583517e79ae0201ea780da7ef80000000100000dd4
 postimage in a certain
way.  -S<block-of-text> and -G<regular-expression> options are used to
specify different ways these strings are sought.

"-S<block-of-text>" detects filepairs whose preimage and postimage
have different number of occurrences of the specified block of text.
By definition, it will not detect in-file moves.  Also, when a
changeset moves a file wholesale without affecting the interesting
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.

"-G<regular-expression>" (mnemonic: grep) detects filepairs whose
textual diff has an added or a deleted line that matches the given
regular expression.  This means that it will detect in-file (or what
rename-detection considers the same file) moves, which is noise.  The
implementation runs diff twice and greps, and this can be quite
expensive.  To speed things up, binary files without textconv filters
will be ignored.

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.

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

This is used to reorder the filepairs according to the user's
(or project's) taste, and is controlled by the -O option to the
'git diff-{asterisk}' commands.

This takes a text file each of whose lines is a shell glob
pattern.  Filepairs that match a glob pattern on an earlier line
in the file are output before ones that match a later line, and
filepairs that do not match any glob pattern are output last.

As an example, a typical orderfile for the core Git probably
would look like this:

------------------------------------------------
README
Makefile
Documentation
*.h
*.c
t
------------------------------------------------

diffcore-rotate: For Changing At Which Path Output Starts
---------------------------------------------------------

This transformation takes one pathname, and rotates the set of
filepairs so that the filepair for the given pathname comes first,
optionally discarding the paths that come before it.  This is used
to implement the `--skip-to` and the `--rotate-to` options.  It is
an error when the specified pathname is not in the set of filepairs,
but it is not useful to error out when used with "git log" family of
commands, because it is unreasonable to expect that a given path
would be modified by each and every commit shown by the "git log"
command.  For this reason, when used with "git log", the filepair
that sorts the same as, or the first one that sorts after, the given
pathname is where the output starts.

Use of this transformation combined with diffcore-order will produce
unexpected results, as the input to this transformation is likely
not sorted when diffcore-order is in effect.


SEE ALSO
--------
linkgit:git-diff[1],
linkgit:git-diff-files[1],
linkgit:git-diff-index[1],
linkgit:git-diff-tree[1],
linkgit:git-format-patch[1],
linkgit:git-log[1],
linkgit:gitglossary[7],
link:user-manual.html[The Git User's Manual]

GIT
---
Part of the linkgit:git[1] suite

Title: Git Diffcore Transformations: Filtering and Sorting
Summary
Git's diffcore transformations include diffcore-pickaxe for detecting string changes, diffcore-order for sorting output based on filenames, and diffcore-rotate for changing the starting path of output, allowing for customized diff output and easier review of changes.