Diff Buddy!
This is a small utility to help with diffs on really large pull requests. To use:
- Clone the repo you're looking at (add and fetch all remotes, if necessary)
- Run diff-buddy - if you run from within the repo, it will default to diff against master
- Filter down results iteratively at the command-line with subsequent runs until you end up seeing a useful changeset
Options
diff-buddy has help which can be invoked from the command-line with --help
:
diff-buddy {args}
-a, --at [number] Show the diff at the provided index only
-f, --from-branch [text] Starting branch for the diff (master)
-h, --help shows this help
-I, --ignore-files [text] Regular expressions for files to ignore completely
-i, --ignore-lines [text] Regular expressions for lines to ignore when deciding on interesting files
--ignore-whitespace Ignore whitespace changes, even those spanning multiple lines, when deciding on interesting files
-l, --limit [number] Limit the number of files to list (2147483647)
-o, --offset [number] Start printing from this offset (0)
-r, --repo [text] (.)
-S, --show-indexes Show the numeric index for each file
--show-operations Show the operation which this file has undergone: (A)dded, (D)eleted, (M)odified, (R)enamed
-s, --show-patches Whether or not to show patches for files
-t, --to-branch [text] Later branch to diff with
Negate any flag argument with --no-{option}
(note that flags can be negated with --no-
, eg --no-show-indexes
)
Building filters
The whole point of diff-buddy is to reduce the number of files you need to look at to understand a large pull request. Sometimes, a pull-request has many files which have changed but in an insignificant way, eg because of a namespace rename or whitespace formatting.
The process, then, is as follows, for slimming down what would be interesting when comparing some satellite branch in a local repo to master:
- Check out the satellite branch of interest
- Make sure you've got the latest:
git pull --rebase
- Start with a plain old
diff-buddy.exe
run in the repository to get a feel for the size of the diff - Scan for files which aren't of interest - perhaps you don't care about test files:
diff-buddy --ignore-files Tests.*
- note that --ignore-files and --ignore-lines take regex strings: when working on unix shells like bash and zsh, you may need to surround these with single-quotes to prevent the shell from expanding them
- Enable patches and start looking at smaller clumps of files:
diff-buddy --ignore-files Tests.* --show-patches --limit 10 --offset 0
- increase the offset by 10 at a time and look for uninteresting patterns to exclude
- Exclude files with uninteresting changes:
diff-buddy --ignore-files Tests.* --ignore-lines ^using --show-patches --limit 10 --offset 10
- this ignores files where the only changes are to
using
statements, still only outputting 10 files, after an offset of 10
- this ignores files where the only changes are to
- Add to the ignores for a few iterations until you can do
diff-buddy --ignore-files {...} --ignore-lines {...}
- and end up with a small enough set of files that you are willing to review full patches for
- Now run with your prior commandline and
--review
to see each file, one-by-one