# Patchutils

Tim Waugh

    twaugh@redhat.com

Package maintainer

## Man pages

interdiff

1

interdiff

show differences between two diff files

    	  interdiff

    	    -p n
    	    --strip-match=n

    	    -U n
    	    --unified=n

    	    -d PAT
    	    --drop-context=PAT

    	    -q
    	    --quiet

    	    -z
    	    --decompress

    	    -b
    	    --ignore-space-change

    	    -B
    	    --ignore-blank-lines

    	    -i
    	    --ignore-case

    	    -w
    	    --ignore-all-space

    	    --interpolate
    	    --combine
    	    --flip

    	  --no-revert-omitted
    	  diff1
    	  diff2

    	  interdiff

    	    --help
    	    --version

#### Description

`interdiff` creates a unified format diff that expresses the difference between two diffs. The diffs must both be relative to the same files. For best results, the diffs must have at least three lines of context.

To reverse a patch, use `/dev/null` for `diff2`.

To reduce the amount of context in a patch, use:

    interdiff -U1 /dev/null patchfile

Since `interdiff` doesn't have the advantage of being able to look at the files that are to be modified, it has stricter requirements on the input format than

patch

1 does. The output of GNU diff will be okay, even with extensions, but if you intend to use a hand-edited patch it might be wise to clean up the offsets and counts using

recountdiff

1 first.

Note, however, that the two patches must both be relative to the versions of the same original set of files.

The diffs may be in context format. The output, however, will be in unified format.

#### Options

`-h`

- Ignored, for compatibility with older versions of interdiff. This option will go away soon.

`-p` `n`, `--strip-match=`n``

- When comparing filenames, ignore the first `n` pathname components from both patches. (This is similar to the `-p` option to GNU

  patch

  1 .)

`-q`, `--quiet`

- Quieter output. Don't emit rationale lines at the beginning of each patch.

`-U` `n`, `--unified=`n``

- Attempt to display `n` lines of context (requires at least `n` lines of context in both input files). (This is similar to the `-U` option to GNU

  diff

  1 .)

`-d` `PATTERN`, `--drop-context=`PATTERN``

- Don't display any context on files that match the shell wildcard `PATTERN`. This option can be given multiple times.

  Note that the interpretation of the shell wildcard pattern does not count slash characters or periods as special (in other words, no flags are given to `fnmatch`). This is so that */basename-type patterns can be given without limiting the number of pathname components.

`-i`, `--ignore-case`

- Consider upper- and lower-case to be the same.

`-w`, `--ignore-all-space`

- Ignore whitespace changes in patches.

`-b`, `--ignore-space-change`

- Ignore changes in the amount of whitespace.

`-B`, `--ignore-blank-lines`

- Ignore changes whose lines are all blank.

`-z`, `--decompress`

- Decompress files with extensions .gz and .bz2.

`--interpolate`

- Run as interdiff. This is the default.

`--combine`

- Run as combinediff. See

  combinediff

  1 for more information about how the behaviour is altered in this mode.

`--no-revert-omitted`

- (For interpolation mode only) When a file is changed by the first patch but not by the second, don't revert that change.

`--help`

- Display a short usage message.

`--version`

- Display the version number of interdiff.

#### Examples

Basic usage:

    interdiff -z 3.2pre1.patch.gz 3.2pre2.patch.gz

Reversing a patch:

    interdiff patch /dev/null

Reversing part of a patch (and ignoring the rest):

    filterdiff -i file.c patchfile | \
      interdiff /dev/stdin /dev/null

#### Bugs

There are currently no known bugs in interdiff; but there are some caveats. If you find a bug, please report it (along with a minimal test case) to Tim Waugh twaugh@redhat.com.

There are some sets of patches in which there is just not enough information to produce a proper interdiff. In this case, the strategy employed is to revert the original patch and apply the new patch. This, unfortunately, means that interdiffs are not guaranteed to be reversible.

#### See also

combinediff

1

combinediff

1

combinediff

create a cumulative unified patch from two incremental patches

    	  combinediff

    	    -p n
    	    --strip-match=n

    	    -U n
    	    --unified=n

    	    -d PAT
    	    --drop-context=PAT

    	    -q
    	    --quiet

    	    -z
    	    --decompress

    	    -b
    	    --ignore-space-change

    	    -B
    	    --ignore-blank-lines

    	    -i
    	    --ignore-case

    	    -w
    	    --ignore-all-space

    	    --interpolate
    	    --combine

    	  diff1
    	  diff2

    	  combinediff

    	    --help
    	    --version

#### Description

combinediff creates a unified diff that expresses the sum of two diffs. The diff files must be listed in the order that they are to be applied. For best results, the diffs must have at least three lines of context.

Since `combinediff` doesn't have the advantage of being able to look at the files that are to be modified, it has stricter requirements on the input format than

patch

1 does. The output of GNU diff will be okay, even with extensions, but if you intend to use a hand-edited patch it might be wise to clean up the offsets and counts using

recountdiff

1 first.

Note, however, that the two patches must be in strict incremental order. In other words, the second patch must be relative to the state of the original set of files after the first patch was applied.

The diffs may be in context format. The output, however, will be in unified format.

#### Options

`-p` `n`, `--strip-match=`n``

- When comparing filenames, ignore the first `n` pathname components from both patches. (This is similar to the `-p` option to GNU

  patch

  1 .)

`-q`, `--quiet`

- Quieter output. Don't emit rationale lines at the beginning of each patch.

`-U` `n`, `--unified=`n``

- Attempt to display `n` lines of context (requires at least `n` lines of context in both input files). (This is similar to the `-U` option to GNU

  diff

  1 .)

`-d` `pattern`, `--drop-context=`PATTERN``

- Don't display any context on files that match the shell wildcard `pattern`. This option can be given multiple times.

  Note that the interpretation of the shell wildcard pattern does not count slash characters or periods as special (in other words, no flags are given to `fnmatch`). This is so that */basename-type patterns can be given without limiting the number of pathname components.

`-i`, `--ignore-case`

- Consider upper- and lower-case to be the same.

`-w`, `--ignore-all-space`

- Ignore whitespace changes in patches.

`-b`, `--ignore-space-change`

- Ignore changes in the amount of whitespace.

`-B`, `--ignore-blank-lines`

- Ignore changes whose lines are all blank.

`-z`, `--decompress`

- Decompress files with extensions .gz and .bz2.

`--interpolate`

- Run as interdiff. See

  interdiff

  1 for more information about how the behaviour is altered in this mode.

`--combine`

- Run as combinediff. This is the default.

`--help`

- Display a short usage message.

`--version`

- Display the version number of combinediff.

#### Bugs

The `-U` option is a bit erratic: it can control the amount of context displayed for files that are modified in both patches, but not for files that only appear in one patch (which appear with the same amount of context in the output as in the input).

#### See also

interdiff

1

filterdiff

1

filterdiff

extract or exclude diffs from a diff file

    	  filterdiff

    	    -i PATTERN
    	    --include=PATTERN

    	    -I FILE
    	    --include-from-file=FILE

    	    -p n
    	    --strip-match=n

    	  --strip=n
    	  --addprefix=PREFIX
    	  --addoldprefix=PREFIX
    	  --addnewprefix=PREFIX

    	    -x PATTERN
    	    --exclude=PATTERN

    	    -X FILE
    	    --exclude-from-file=FILE

    	    -v
    	    --verbose

    	  --clean

    	    -z
    	    --decompress

    	    -# RANGE
    	    --hunks=RANGE

    	  --lines=RANGE

    	    -FRANGE
    	    --files=RANGE

    	  --annotate
    	  --format=FORMAT
    	  --as-numbered-lines=WHEN
    	  --remove-timestamps
    	  file

    	  filterdiff

    	    --help
    	    --version
    	    --list
    	    --grep ...

#### Description

You can use filterdiff to obtain a patch that applies to files matching the shell wildcard `PATTERN` from a larger collection of patches. For example, to see the patches in `patch-2.4.3.gz` that apply to all files called `lp.c`:

    filterdiff -z -i '*/lp.c' patch-2.4.3.gz

If neither `-i` nor `-x` options are given, `-i '*'` is assumed. This way `filterdiff` can be used to clean up an existing diff file, removing redundant lines from the beginning (eg. the text from the mail body) or between the chunks (eg. in CVS diffs). To extract pure patch data, use a command like this:

    filterdiff message-with-diff-in-the-body > patch

Note that the interpretation of the shell wildcard pattern does not count slash characters or periods as special (in other words, no flags are given to `fnmatch`). This is so that */basename-type patterns can be given without limiting the number of pathname components.

You can use both unified and context format diffs with this program.

#### Options

`-i` `PATTERN`, `--include=`PATTERN``

- Include only files matching `PATTERN`. All other lines in the input are suppressed.

`-I` `FILE`, `--include-from-file=`FILE``

- Include only files matching any pattern listed in `FILE`, one pattern per line. All other lines in the input are suppressed.

`-x` `PATTERN`, `--exclude=`PATTERN``

- Exclude files matching `PATTERN`. All other lines in the input are displayed.

`-X` `FILE`, `--exclude-from-file=`FILE``

- Exclude files matching any pattern listed in `FILE`, one pattern per line. All other lines in the input are displayed.

`-p` `n`, `--strip-match=`n``

- When matching, ignore the first `n` components of the pathname.

`-#` `RANGE`, `--hunks`=`RANGE`

- Only include hunks within the specified `RANGE`. Hunks are numbered from 1, and the range is a comma-separated list of numbers or first-last spans, optionally preceded by a modifier 'x' which inverts the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction.

`--lines`=`RANGE`

- Only include hunks that contain lines from the original file that lie within the specified `RANGE`. Lines are numbered from 1, and the range is a comma-separated list of numbers or first-last spans, optionally preceded by a modifier 'x' which inverts the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction.

`-F`=`RANGE`, `--files`=`RANGE`

- Only include files indicated by the specified `RANGE`. Files are numbered from 1 in the order they appear in the patch input, and the range is a comma-separated list of numbers or first-last spans, optionally preceded by a modifier 'x' which inverts the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction.

`--annotate`

- Annotate each hunk with the filename and hunk number.

`--format`=unified|context

- Use specified output format.

`--strip`=`n`

- Remove the first `n` components of pathnames in the output.

`--addprefix`=`PREFIX`

- Prefix pathnames in the output by `PREFIX`. This will override any individual settings specified with the `--addoldprefix` or `--addnewprefix` options.

`--addoldprefix`=`PREFIX`

- Prefix pathnames for old or original files in the output by `PREFIX`.

`--addnewprefix`=`PREFIX`

- Prefix pathnames for updated or new files in the output by `PREFIX`.

`--as-numbered-lines`=before|after

- Instead of a patch fragment, display the lines of the selected hunks with the line number of the file before (or after) the patch is applied, followed by a TAB character and a colon, at the beginning of each line. Each hunk except the first will have a line consisting of ... before it.

`--remove-timestamps`

- Do not include file timestamps in the output.

`-v`, `--verbose`

- Always show non-diff lines in the output. By default, non-diff lines are only shown when excluding a filename pattern.

`--clean`

- Always remove all non-diff lines from the output. Even when excluding a filename pattern.

`-z`, `--decompress`

- Decompress files with extensions .gz and .bz2.

`--help`

- Display a short usage message.

`--version`

- Display the version number of filterdiff.

`--list`

- Behave like

  lsdiff

  1 instead.

`--grep`

- Behave like

  grepdiff

  1 instead.

#### Examples

To see all patch hunks that affect the first five lines of a C file:

    filterdiff -i '*.c' --lines=-5 < patch

To see the first hunk of each file patch, use:

    filterdiff -#1 patchfile

To see patches modifying a ChangeLog file in a subdirectory, use:

    filterdiff -p1 Changelog

To see the complete patches for each patch that modifies line 1 of the original file, use:

    filterdiff --lines=1 patchfile | lsdiff | \
      xargs -rn1 filterdiff patchfile -i

To see all but the first hunk of a particular patch, you might use:

    filterdiff -p1 -i file.c -#2- foo-patch

If you have a very specific list of hunks in a patch that you want to see, list them:

    filterdiff -#1,2,5-8,10,12,27-

To see the lines of the files that would be patched as they will appear after the patch is applied, use:

    filterdiff --as-numbered-lines=after patch.file

You can see the same context before the patch is applied with:

    filterdiff --as-numbered-lines=before
    patch.file

Filterdiff can also be used to convert between unified and context format diffs:

    filterdiff -v --format=unified context.diff

#### See also

lsdiff

1 ,

grepdiff

1 ,

patchview

1

fixcvsdiff

1

fixcvsdiff

fix problematic diff files

    	  fixcvsdiff
    	  -p
    	  -b
    	  file

#### Description

fixcvsdiff modifies diff files created from the `cvs diff` command, where files have been added or removed. CVS tends to create diff files that

patch

1 mis-interprets. The diff file must retain the lines beginning with Index: in order for the correction to work.

#### Options

`-b`

- Keep a .bak backup file.

`-p`

- Print out the `cvs add` and `cvs remove` commands that must be made after applying the diff, but before running `cvs commit`.

#### See also

diff

1 ,

patch

1 ,

cvs

1

lsdiff

1

lsdiff

show which files are modified by a patch

    	  lsdiff

    	    -n
    	    --line-number

    	    -p n
    	    --strip-match=n

    	  --strip=n
    	  --addprefix=PREFIX

    	    -s
    	    --status

    	    -E
    	    --empty-files-as-removed

    	    -i PATTERN
    	    --include=PATTERN

    	    -x PATTERN
    	    --exclude=PATTERN

    	    -z
    	    --decompress

    	    -# RANGE
    	    --hunks=RANGE

    	  --lines=RANGE

    	    -FRANGE
    	    --files=RANGE

    	    -H
    	    --with-filename

    	    -h
    	    --no-filename

    	    -v
    	    --verbose

    	  file

    	  lsdiff

    	    --help
    	    --version
    	    --filter ...
    	    --grep ...

#### Description

List the files modified by a patch.

You can use both unified and context format diffs with this program.

#### Options

`-n`, `--line-number`

- Display the line number that each patch begins at. If verbose output is requested (using `-nv`), each hunk of each patch is listed as well.

  For each file that is modified, a line is generated containing the line number of the beginning of the patch, followed by a Tab character, followed by the name of the file that is modified. If `-v` is given once, following each of these lines will be one line for each hunk, consisting of a Tab character, the line number that the hunk begins at, another Tab character, the string Hunk #, and the hunk number (starting at 1).

  If the `-v` is given twice in conjunction with `-n` (i.e. `-nvv`), the format is slightly different: hunk-level descriptive text is shown after each hunk number, and the `--number-files` option is enabled.

`-N`, `--number-files`

- File numbers are listed, beginning at 1, before each filename.

`-#` `RANGE`, `--hunks`=`RANGE`

- Only list hunks within the specified `RANGE`. Hunks are numbered from 1, and the range is a comma-separated list of numbers or first-last spans, optionally preceded by a modifier 'x' which inverts the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction.

`--lines`=`RANGE`

- Only list hunks that contain lines from the original file that lie within the specified `RANGE`. Lines are numbered from 1, and the range is a comma-separated list of numbers or first-last spans, optionally preceded by a modifier 'x' which inverts the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction.

`-F`=`RANGE`, `--files`=`RANGE`

- Only list files indicated by the specified `RANGE`. Files are numbered from 1 in the order they appear in the patch input, and the range is a comma-separated list of numbers or first-last spans, optionally preceded by a modifier 'x' which inverts the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction.

`-p` `n`, `--strip-match=`n``

- When matching, ignore the first `n` components of the pathname.

`--strip`=`n`

- Remove the first `n` components of the pathname before displaying it.

`--addprefix`=`PREFIX`

- Prefix the pathname with `PREFIX` before displaying it.

`-s`, `--status`

- Show file additions, modifications and removals. A file addition is indicated by a +, a removal by a -, and a modification by a !.

`-E`, `--empty-files-as-removed`

- Treat empty files as absent for the purpose of displaying file additions, modifications and removals.

`-i` `PATTERN`, `--include=`PATTERN``

- Include only files matching `PATTERN`.

`-x` `PATTERN`, `--exclude=`PATTERN``

- Exclude files matching `PATTERN`.

`-z`, `--decompress`

- Decompress files with extensions .gz and .bz2.

`-H`, `--with-filename`

- Print the name of the patch file containing each patch.

`-h`, `--no-filename`

- Suppress the name of the patch file containing each patch.

`-v`, `--verbose`

- Verbose output.

`--help`

- Display a short usage message.

`--version`

- Display the version number of lsdiff.

`--filter`

- Behave like

  filterdiff

  1 instead.

`--grep`

- Behave like

  grepdiff

  1 instead.

#### See also

filterdiff

1 ,

grepdiff

1 ,

patchview

1

#### Examples

To sort the order of touched files in a patch, you can use:

    lsdiff patch | sort -u | \
      xargs -rn1 filterdiff patch -i

To show only added files in a patch:

    lsdiff -s patch | grep '^+' | \
      cut -c2- | xargs -rn1 filterdiff patch -i

To show the headers of all file hunks:

    lsdiff -n patch | (while read n file
      do sed -ne "$n,$(($n+1))p" patch
    done)

patchview

1

patchview

Without options, show numbered files modified by the patch. With options, behave as filterdiff.

    	  patchview

    	    -n
    	    --line-number

    	    -p n
    	    --strip-match=n

    	  --strip=n
    	  --addprefix=PREFIX

    	    -s
    	    --status

    	    -E
    	    --empty-files-as-removed

    	    -i PATTERN
    	    --include=PATTERN

    	    -x PATTERN
    	    --exclude=PATTERN

    	    -z
    	    --decompress

    	    -# RANGE
    	    --hunks=RANGE

    	  --lines=RANGE

    	    -FRANGE
    	    --files=RANGE

    	    -H
    	    --with-filename

    	    -h
    	    --no-filename

    	    -v
    	    --verbose

    	  file

    	  patchview

    	    --help
    	    --version
    	    --filter ...
    	    --grep ...

#### Description

So what is patchview? It is a wrapper of filterdiff for use with numbered files.

    patchview

(without args) is equivalent to: lsdiff --number

    patchview -F2-

(or with any other args) is equivalent to: filterdiff -F2- (or whatever arguments are supplied)

There are two scripts for working with git (gitdiff and gitdiffview) and two for svn (svndiff and svndiffview).

    svndiff

    gitdiff

(without args) will give the list of files modified

    svndiff -F1

    gitdiff -F1

will show the patch of file #1

    svndiffview

    gitdiffview

pipe all patches through filterdiff to vim - -R (in read-only mode, easy to quit), showing complete patch with color.

    svndiffview -F2

    gitdiffview -F2

(or any other args) will pipe patch of file #2 to vim - -R

#### Options

`-n`, `--line-number`

- Display the line number that each patch begins at. If verbose output is requested (using `-nv`), each hunk of each patch is listed as well.

  For each file that is modified, a line is generated containing the line number of the beginning of the patch, followed by a Tab character, followed by the name of the file that is modified. If `-v` is given once, following each of these lines will be one line for each hunk, consisting of a Tab character, the line number that the hunk begins at, another Tab character, the string Hunk #, and the hunk number (starting at 1).

  If the `-v` is given twice in conjunction with `-n` (i.e. `-nvv`), the format is slightly different: hunk-level descriptive text is shown after each hunk number, and the `--number-files` option is enabled.

`-N`, `--number-files`

- File numbers are listed, beginning at 1, before each filename.

`-#` `RANGE`, `--hunks`=`RANGE`

- Only list hunks within the specified `RANGE`. Hunks are numbered from 1, and the range is a comma-separated list of numbers or first-last spans, optionally preceded by a modifier 'x' which inverts the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction.

`--lines`=`RANGE`

- Only list hunks that contain lines from the original file that lie within the specified `RANGE`. Lines are numbered from 1, and the range is a comma-separated list of numbers or first-last spans, optionally preceded by a modifier 'x' which inverts the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction.

`-F`=`RANGE`, `--files`=`RANGE`

- Only list files indicated by the specified `RANGE`. Files are numbered from 1 in the order they appear in the patch input, and the range is a comma-separated list of numbers or first-last spans, optionally preceded by a modifier 'x' which inverts the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction.

`-p` `n`, `--strip-match=`n``

- When matching, ignore the first `n` components of the pathname.

`--strip`=`n`

- Remove the first `n` components of the pathname before displaying it.

`--addprefix`=`PREFIX`

- Prefix the pathname with `PREFIX` before displaying it.

`-s`, `--status`

- Show file additions, modifications and removals. A file addition is indicated by a +, a removal by a -, and a modification by a !.

`-E`, `--empty-files-as-removed`

- Treat empty files as absent for the purpose of displaying file additions, modifications and removals.

`-i` `PATTERN`, `--include=`PATTERN``

- Include only files matching `PATTERN`.

`-x` `PATTERN`, `--exclude=`PATTERN``

- Exclude files matching `PATTERN`.

`-z`, `--decompress`

- Decompress files with extensions .gz and .bz2.

`-H`, `--with-filename`

- Print the name of the patch file containing each patch.

`-h`, `--no-filename`

- Suppress the name of the patch file containing each patch.

`-v`, `--verbose`

- Verbose output.

`--help`

- Display a short usage message.

`--version`

- Display the version number of patchview.

`--filter`

- Behave like

  filterdiff

  1 instead.

`--grep`

- Behave like

  grepdiff

  1 instead.

#### See also

lsdiff

1 ,

filterdiff

1 ,

grepdiff

1

#### Examples

We can make the following one-line script with the name difftotrunk.sh, to view the differences of two directories or svn repos (trunk and .)

    diff ../trunk . -ru -x .svn | patchview "$@"

    ./difftotrunk.sh , will show all different files and his number.

    ./difftotrunk.sh -F3,4 , will show the differences of files #3 and #4 only.

    ./difftotrunk.sh -F3 -#1 , will show only hunk #1 of file #3.

    ./difftotrunk.sh -F3 -#x1 , will show the differences of files #3 without hunk #1 (x means that exclude).

splitdiff

1

splitdiff

separate out incremental patches

    	  splitdiff
    	  -a
    	  -d
    	  -D dir
    	  -p n
    	  -E
    	  file

    	  splitdiff

    	    --help
    	    --version

#### Description

If you have a patch file composed of several incremental patches, you can use splitdiff to separate them out. You may want to do this in preparation for re-combining them with

combinediff

1.

The effect of running splitdiff is to separate its input into a set of output files, with no output file patching the same file more than once.

#### Options

`-a`

- Split out every single file-level patch.

`-d`

- Create file names such as `a_b.c.patch` for a patch that modifies `a/b.c`.

`-D` `dir`

- Write output files into subdirectory `dir`. Implies `-d`.

`-p` `n`

- Strip the first `n` components of the pathname to aid comparisons.

`-E`

- Don't use .patch filename extension when writing output files.

`--help`

- Display a short usage message.

`--version`

- Display the version number of splitdiff.

#### See also

combinediff

1 ,

lsdiff

1

rediff

1

rediff

editdiff

fix offsets and counts of a hand-edited diff

    	  rediff
    	  ORIGINAL
    	  EDITED

    	  rediff
    	  EDITED

    	  rediff

    	    --help
    	    --version

    	  editdiff
    	  FILE

    	  editdiff

    	    --help
    	    --version

#### Description

You can use rediff to correct a hand-edited unified diff. Take a copy of the diff you want to edit, and edit it without changing any offsets or counts (the lines that begin @@). Then run rediff, telling it the name of the original diff file and the name of the one you have edited, and it will output the edited diff file but with corrected offsets and counts.

A small script, editdiff, is provided for editing a diff file in-place.

The types of changes that are currently handled are:

- Modifying the text of any file content line (of course).

- Adding new line insertions or deletions.

- Adding, changing or removing context lines. Lines at the context horizon are dealt with by adjusting the offset and/or count.

- Adding a single hunk (@@-prefixed section).

- Removing multiple hunk (@@-prefixed sections).

Alternatively, if only one argument is provided, it is taken to be the edited file and the counts and offsets are adjusted as appropriate. Some assumptions are made when used in this mode. See

recountdiff

1 for more information.

#### Options

`--help`

- Display a short usage message.

`--version`

- Display the version number of rediff.

#### See also

interdiff

1 ,

recountdiff

1

grepdiff

1

grepdiff

show files modified by a diff containing a regex

    	  grepdiff

    	    -n
    	    --line-number

    	    -N
    	    --number-files

    	    -p n
    	    --strip-match=n

    	  --strip=n
    	  --addprefix=PREFIX
    	  --addoldprefix=PREFIX
    	  --addnewprefix=PREFIX

    	    -s
    	    --status

    	    -i PATTERN
    	    --include=PATTERN

    	    -I FILE
    	    --include-from-file=FILE

    	    -x PATTERN
    	    --exclude=PATTERN

    	    -X FILE
    	    --exclude-from-file=FILE

    	    -# RANGE
    	    --hunks=RANGE

    	  --lines=RANGE

    	    -FRANGE
    	    --files=RANGE

    	  --annotate
    	  --as-numbered-lines=WHEN
    	  --format=FORMAT
    	  --remove-timestamps

    	    -v
    	    --verbose

    	    -z
    	    --decompress

    	    -E
    	    --extended-regexp

    	    -H
    	    --with-filename

    	    -h
    	    --no-filename

    	  --output-matching=WHAT
    	  --only-match=WHAT

    	    REGEX
    	    -f FILE

    	  file

    	  grepdiff

    	    --help
    	    --version
    	    --list
    	    --filter ...

#### Description

For each file modified by a patch, if the patch hunk contains the `REGEX` then the file's name is printed.

The regular expression is treated as POSIX Basic Regular Expression syntax, unless the `-E` option is given in which case POSIX Extended Regular Expression syntax is used.

For example, to see the patches in `my.patch` which contain the regular expression pf_gfp_mask, use:

    grepdiff pf_gfp_mask my.patch | \
      xargs -rn1 filterdiff my.patch -i

You can use both unified and context format diffs with this program.

#### Options

`-n`, `--line-number`

- Display the line number that each patch begins at. If verbose output is requested, each matching hunk is listed as well.

  For a description of the output format see

  lsdiff

  1 .

`-N`, `--number-files`

- File numbers are listed, beginning at 1, before each filename.

`-p` `n`, `--strip-match=`n``

- When matching, ignore the first `n` components of the pathname.

`--strip`=`n`

- Remove the first `n` components of the pathname before displaying it.

`--addprefix`=`PREFIX`

- Prefix the pathname with `PREFIX` before displaying it. This will override any individual settings specified with the `--addoldprefix` or `--addnewprefix` options.

`--addoldprefix`=`PREFIX`

- Prefix pathnames for old or original files in the output by `PREFIX`.

`--addnewprefix`=`PREFIX`

- Prefix pathnames for updated or new files in the output by `PREFIX`.

`-s`

- Show file additions, modifications and removals. A file addition is indicated by a +, a removal by a -, and a modification by a !.

`-i` `PATTERN`, `--include=`PATTERN``

- Include only files matching `PATTERN`.

`-I` `FILE`, `--include-from-file=`FILE``

- Include only files matching any pattern listed in `FILE`, one pattern per line. All other lines in the input are suppressed.

`-x` `PATTERN` `--exclude=`PATTERN``

- Exclude files matching `PATTERN`.

`-X` `FILE`, `--exclude-from-file=`FILE``

- Exclude files matching any pattern listed in `FILE`, one pattern per line. All other lines in the input are displayed.

`-#` `RANGE`, `--hunks`=`RANGE`

- Only include hunks within the specified `RANGE`. Hunks are numbered from 1, and the range is a comma-separated list of numbers or first-last spans, optionally preceded by a modifier 'x' which inverts the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction.

`--lines`=`RANGE`

- Only list hunks that contain lines from the original file that lie within the specified `RANGE`. Lines are numbered from 1, and the range is a comma-separated list of numbers or first-last spans, optionally preceded by a modifier 'x' which inverts the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction.

`-F`=`RANGE`, `--files`=`RANGE`

- Only list files indicated by the specified `RANGE`. Files are numbered from 1 in the order they appear in the patch input, and the range is a comma-separated list of numbers or first-last spans, optionally preceded by a modifier 'x' which inverts the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction.

`--annotate`

- Annotate each hunk with the filename and hunk number.

`--as-numbered-lines`=before|after

- Instead of a patch fragment, display the lines of the selected hunks with the line number of the file before (or after) the patch is applied, followed by a TAB character and a colon, at the beginning of each line. Each hunk except the first will have a line consisting of ... before it.

`--format`=unified|context

- Use specified output format.

`--remove-timestamps`

- Do not include file timestamps in the output.

`-z`, `--decompress`

- Decompress files with extensions .gz and .bz2.

`-E`, `--extended-regexp`

- Use POSIX Extended Regular Expression syntax.

`-H`, `--with-filename`

- Print the name of the patch file containing each match.

`-h`, `--no-filename`

- Suppress the name of the patch file containing each match.

`-f` `FILE`, `--file=`FILE``

- Read regular expressions from `FILE`, one per line.

`--output-matching`=hunk|file

- Display the matching hunk-level or file-level diffs.

`--only-match`=rem|removals|add|additions|mod|modifications|all

- Limit regex matching to removals, additions, modifications or the whole hunk.

`--help`

- Display a short usage message.

`--version`

- Display the version number of grepdiff.

`--filter`

- Behave like

  filterdiff

  1 instead.

`--list`

- Behave like

  lsdiff

  1 instead.

#### See also

filterdiff

1 ,

lsdiff

1 ,

patchview

1

recountdiff

1

recountdiff

recompute patch counts and offsets

    	  recountdiff
    	  file

    	  recountdiff

    	    --help
    	    --version

#### Description

`recountdiff` recomputes the counts and offsets in unified context diffs. It does this in two passes: first the counts are corrected by inspection of the actual patch lines, and then the offsets are adjusted according to the computed counts.

The corrected diff is sent to standard output.

#### Options

`--help`

- Display a short usage message.

`--version`

- Display the version number of recountdiff.

#### Limitations

There are some things that cannot be dealt with. If you have removed the first context line in a hunk, for example, there is no way for `recountdiff` to know that. For more precise fixing up, use

rediff

1 , which uses the original and modified diffs.

#### See also

rediff

1

unwrapdiff

1

unwrapdiff

demangle word-wrapped patches

    	  unwrapdiff
    	  -v
    	  file

    	  unwrapdiff

    	    --help
    	    --version

#### Description

`unwrapdiff` demangles patches that have been word-wrapped, in an attempt to make them useful.

The corrected diff is sent to standard output. Note that you will probably need to use the `-l` option when applying the patch, in order to ignore any whitespace differences there may be.

#### Options

`-v`

- Verbose operation. A list of lines that are modified in a way that might be wrong is sent to stderr.

`--help`

- Display a short usage message.

`--version`

- Display the version number of unwrapdiff.

#### Limitations

Some heuristics are used to decide whether use a space to recombine a wrapped line, or just join them together. Currently this is done by comparing with last three characters of a line with the first two characters of its continuation, and using a space if any of them are different.

The patch needs to have been valid before being word-wrapped.

The last line of a hunk is nearly always ambiguous. If the next line begins @@, Index: , diff or --- then it is taken to be complete; otherwise it is unwrapped using the next line.

dehtmldiff

1

dehtmldiff

get usable diff from an HTML page

    	  dehtmldiff
    	  file

    	  dehtmldiff

    	    --help
    	    --version

#### Description

`dehtmldiff` creates usable diff files from HTML pages. This is useful in the scenario where a patch has been posted to a mailing list viewable via a web page.

The corrected diff is sent to standard output. Note that you will probably need to use the `-l` option when applying the patch, in order to ignore any whitespace differences there may be.

#### Options

`--help`

- Display a short usage message.

`--version`

- Display the version number of dehtmldiff.

#### Limitations

The way this command works is fairly primitive; it boils down to some simple text replacements, followed by an `unwrapdiff` pass. As a result, all of the limitations that apply to `unwrapdiff` also apply to `dehtmldiff`.

flipdiff

1

flipdiff

exchange the order of two incremental patches

    	  flipdiff

    	    -p n
    	    --strip-match=n

    	    -U n
    	    --unified=n

    	    -d PAT
    	    --drop-context=PAT

    	    -q
    	    --quiet

    	    -z
    	    --decompress

    	    -b
    	    --ignore-space-change

    	    -B
    	    --ignore-blank-lines

    	    -i
    	    --ignore-case

    	    -w
    	    --ignore-all-space

    	  --in-place
    	  diff1
    	  diff2

    	  flipdiff

    	    --help
    	    --version

#### Description

`flipdiff` exchanges the order of two patch files that apply one after the other. The patches must be clean: the context lines must match and there should be no mis-matched offsets.

The swapped patches are sent to standard output, with a marker line (`=== 8< === cut here === 8< ===`) between them, unless the `--in-place` option is passed. In that case, the output is written back to the original input files.

#### Options

`-p` `n`, `--strip-match=`n``

- When comparing filenames, ignore the first `n` pathname components from both patches. (This is similar to the `-p` option to GNU

  patch

  1 .)

`-q`, `--quiet`

- Quieter output. Don't emit rationale lines at the beginning of each patch.

`-U` `n`, `--unified=`n``

- Attempt to display `n` lines of context (requires at least `n` lines of context in both input files). (This is similar to the `-U` option to GNU

  diff

  1 .)

`-d` `pattern`, `--drop-context=`PATTERN``

- Don't display any context on files that match the shell wildcard `pattern`. This option can be given multiple times.

  Note that the interpretation of the shell wildcard pattern does not count slash characters or periods as special (in other words, no flags are given to `fnmatch`). This is so that */basename-type patterns can be given without limiting the number of pathname components.

`-i`, `--ignore-case`

- Consider upper- and lower-case to be the same.

`-w`, `--ignore-all-space`

- Ignore whitespace changes in patches.

`-b`, `--ignore-space-change`

- Ignore changes in the amount of whitespace.

`-B`, `--ignore-blank-lines`

- Ignore changes whose lines are all blank.

`-z`, `--decompress`

- Decompress files with extensions .gz and .bz2.

`--in-place`

- Write output to the original input files.

`--help`

- Display a short usage message.

`--version`

- Display the version number of flipdiff.

#### Limitations

This is only been very lightly tested, and may not even work. Using `--in-place` is not recommended at the moment.

There are some cases in which it is not possible to meaningfully flip patches without understanding the semantics of the content. This program only uses complete lines that appear at some stage during the application of the two patches, and never composes a line from parts.

Because of this, it is generally a good idea to read through the output to check that it makes sense.

espdiff

1

espdiff

apply the appropriate transformation to a set of patches

    	  espdiff
    	  --deep-brainwave-mode
    	  --recurse
    	  --compare
    	  file

    	  espdiff

    	    --help
    	    --version

#### Description

`espdiff` applies the appropriate transformation to a patch or set of patches, depending on what you intend to accomplish.

The input patches must be clean: in other words they must apply without fuzz or offsets in whichever order they are meant to be applied. The exception is if you intend `espdiff` to clean them for you (good luck).

You may find it useful to cross your fingers while the program performs its task, or to screw your eyes tight shut while imagining it doing the right thing.

#### Options

`--deep-brainwave-mode`

- Probes your brain deeply in a manner that takes longer, but produces better extra sensory results.

`--recurse`

- Recurses neural pathways throughout all parts of the brain, in some cases determining code changes you might make far off in the future. You may feel a gentle tickling sensation when using this option.

`--compare`

- Allows the program to scan the current directory examining existing patches to determine areas of code you are likely to change again, and concentrating on these areas more closely.

`--help`

- Display a short usage message.

`--version`

- Display the version number of espdiff.

#### Limitations

Do not use this program while sleep-walking, or before your first cup of coffee.

There are some cases in which it is not possible to determine what the intention of the user is. In these cases, you should construct the output you desire using an editor, and send the input files together with the desired output file to Tim Waugh twaugh@redhat.com asking for a new diff tool.