diffgrep

command
v0.0.0-...-f64633d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package diffgrep prints portions of unified diff output, as produced many tools including git, that match (or don't match) a given pattern. If the input is a valid unified diff, the output is too.

For example, to exclude all Go test files from some git diff:

git diff some-other-branch | diffgrep -v -f '_test\.go$'

Usage:

diffgrep regex [flags]
Grep unified diff output for a pattern.
  -L	exclude whole files if they contain a match
  -a	search context too
  -d	search deleted content
  -f	grep file names instead of content
  -i	search inserted content
  -l	include whole files if they contain a match
  -v	invert results

See https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html for details of the format.

Credit to https://godoc.org/sourcegraph.com/sourcegraph/go-diff/diff for making it possible to implement this in less than an hour.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL