Skip to content
forked from twaugh/patchutils

About

Manipulate patch files

Resources

Contributing

Stars

2 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

Patchutils

CI codecov

A collection of tools that operate on patch files.

Overview

Patchutils is a small collection of programs that operate on patch files. It provides utilities for manipulating, analyzing, and transforming patch files in various ways.

Tools

Core Tools

  • interdiff - Generates an incremental patch from two patches against a common source. For example, if you have applied a pre-patch to a source tree, and wish to apply another pre-patch (which is against the same original source tree), you can use interdiff to generate the patch that you need to apply. You can also use this to review changes between two pre-patches.

  • combinediff - Generates a single patch from two incremental patches, allowing you to merge patches together. The resulting patch file only alters each file once.

  • filterdiff - Selects the portions of a patch file that apply to files matching (or, alternatively, not matching) a shell wildcard.

  • rediff - Corrects hand-edited patches, by comparing the original patch with the modified one and adjusting the offsets and counts.

Analysis Tools

  • lsdiff - Displays a short listing of affected files in a patch file, along with (optionally) the line numbers of the start of each patch.

  • grepdiff - Displays a list of the files modified by a patch where the patch contains a given regular expression.

Utility Tools

  • splitdiff - Separates out patches from a patch file so that each new patch file only alters any given file once. In this way, a file containing several incremental patches can be split into individual incremental patches.

  • fixcvsdiff - Corrects the output of 'cvs diff'.

  • recountdiff - Fixes up counts and offsets in a unified diff.

  • unwrapdiff - Fixes word-wrapped unified diffs.

  • flipdiff - Exchanges the order of two patches.

  • move-to-front - An example of how flipdiff can be used.

  • dehtmldiff - Extracts a diff from an HTML page.

  • editdiff - Edit a patch file interactively.

  • espdiff - Apply the appropriate transformation to a patch.

Viewer Tools

  • patchview - View patches with syntax highlighting.

  • gitdiff / gitdiffview - Git-specific diff viewing tools.

  • gitshow / gitshowview - Git-specific show viewing tools.

  • svndiff / svndiffview - Subversion-specific diff viewing tools.

Building from the Git repository

./gnulib-update.sh
./bootstrap
./configure
make -j$(nproc)

The gnulib-update.sh and ./bootstrap steps are only needed once (or when configure.ac / Makefile.am change). After that, just ./configure && make is sufficient.

This requires automake and autoconf to be installed on your system.

Installation

make install

Testing

make check

Run a single test:

make check TESTS=tests/addhunk1/run-test

Stress-testing fuzzy mode

The tests/stress-test-fuzzy.sh script mass-tests interdiff --fuzzy by comparing every commit in a git range against itself. Since both inputs are identical, any output from interdiff indicates a bug. This is effective against any git repository, but large repositories like the Linux kernel are particularly useful because they exercise a wide variety of patch shapes: hunks at line 1 with no pre-context, files ending without a newline, file creations and deletions, mode-only changes, multi-thousand-line diffs, whitespace-damaged patches, hunks with duplicate context lines, and so on.

INTERDIFF=./src/interdiff ./tests/stress-test-fuzzy.sh /path/to/linux v2.6.12-rc2..v6.19

Only commits that produce non-empty output or a non-zero exit code are printed. The JOBS and INTERDIFF environment variables can be used to tune parallelism and the interdiff binary path respectively.

Requirements

  • A C compiler (GCC recommended)
  • Standard Unix utilities (diff, patch)
  • Perl (for some scripts)
  • Optional: xmlto (for building documentation)
  • Optional: PCRE2 library (for enhanced regex support)

Documentation

Manual pages are available for all tools. After installation, you can access them with:

man interdiff
man filterdiff
# etc.

About

Manipulate patch files

Resources

Contributing

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages