| GREPDIFF(1) | Man pages | GREPDIFF(1) |
NAME
grepdiff - show files modified by a diff containing a regex
SYNOPSIS
grepdiff [[-n] | [--line-number]] [[-N] | [--number-files]] [[-p n] | [--strip-match=n]] [--strip=n] [--git-prefixes=strip|keep] [--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. When compiled with PCRE2 support, PCRE regular expressions are used instead of POSIX regular expressions, and the -E option has no effect since PCRE already supports extended regular expression features by default.
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 unified, context, and Git format diffs with this program. Git format includes support for binary files, file renames, permission mode changes, and other Git-specific diff features.
OPTIONS
-n, --line-number
For a description of the output format see lsdiff(1).
-N, --number-files
-pn, --strip-match=n
--strip=n
--git-prefixes=strip|keep
--addprefix=PREFIX
--addoldprefix=PREFIX
--addnewprefix=PREFIX
-s
-iPATTERN, --include=PATTERN
-IFILE, --include-from-file=FILE
-x PATTERN --exclude=PATTERN
-XFILE, --exclude-from-file=FILE
-#RANGE, --hunks=RANGE
--lines=RANGE
-F=RANGE, --files=RANGE
--annotate
--as-numbered-lines=before|after|original-before|original-after
The before and after options show line numbers adjusted for any skipped hunks. The original-before and original-after options show line numbers as they appear in the original diff, preserving the original line number context. This is useful for CI/CD systems that need to report errors on the exact line numbers from the original diff.
--format=unified|context
--remove-timestamps
-z, --decompress
-E, --extended-regexp
-H, --with-filename
-h, --no-filename
-fFILE, --file=FILE
--output-matching=hunk|file
--only-match=rem|removals|add|additions|mod|modifications|all
--help
--version
--filter
--list
EXAMPLES
Git format diffs are fully supported. For example, to find files in a git patch that contain changes to malloc calls:
grepdiff "malloc" git-patch.patch
Note that grepdiff searches in the hunk content (the actual code changes), not in Git metadata like rename headers. Files with only renames or mode changes (no content hunks) won't be found even if the pattern appears in the Git headers.
SEE ALSO
AUTHOR
Tim Waugh <twaugh@redhat.com>
| 10 Feb 2011 | patchutils |