No description
  • Go 99.4%
  • Makefile 0.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-04-30 16:30:00 +02:00
.github/workflows chore: update linter and workflows 2026-04-30 16:30:00 +02:00
cmd/revgrep chore: update linter and workflows 2026-04-30 16:30:00 +02:00
testdata fix: ignore color on diff 2022-08-04 04:00:02 +02:00
.gitignore Initial commit 2016-09-19 21:35:35 +09:30
.golangci.yml chore: update linter and workflows 2026-04-30 16:30:00 +02:00
go.mod chore: update linter and workflows 2026-04-30 16:30:00 +02:00
go.sum Use bufio.Reader to handle large git histories 2020-02-18 16:59:20 -05:00
issue.go chore: isolate Issue 2025-01-18 03:23:29 +01:00
LICENSE Initial commit 2016-09-19 21:35:35 +09:30
Makefile chore: add Makefile and linter configuration 2022-07-31 05:33:49 +02:00
patch.go chore: update linter and workflows 2026-04-30 16:30:00 +02:00
patch_test.go chore: update linter and workflows 2026-04-30 16:30:00 +02:00
README.md docs: fix headings 2025-01-18 03:35:42 +01:00
revgrep.go chore: update linter 2025-03-25 05:11:13 +01:00
revgrep_test.go chore: update linter and workflows 2026-04-30 16:30:00 +02:00

Overview

revgrep is a CLI tool used to filter static analysis tools to only lines changed based on a commit reference.

Install

go install github.com/golangci/revgrep/cmd/revgrep@latest

Usage

In the scenario below, a change was made causing a warning in go vet on line 5, but go vet will show all warnings. Using revgrep, you can show only warnings for lines of code that have been changed (in this case, hiding line 6).

[user@host dir (master)]$ go vet
main.go:5: missing argument for Sprintf("%s"): format reads arg 1, have only 0 args
main.go:6: missing argument for Sprintf("%s"): format reads arg 1, have only 0 args
[user@host dir (master)]$ go vet |& revgrep
main.go:5: missing argument for Sprintf("%s"): format reads arg 1, have only 0 args

|& is shown above as many static analysis programs write to stderr, not stdout, |& combines both stderr and stdout. It could also be achieved with go vet 2>&1 | revgrep.

revgrep CLI tool will return an exit status of 1 if any issues match, else it will return 0. Consider using ${PIPESTATUS[0]} for the exit status of the go vet command in the above example.

Usage: revgrep [options] [from-rev] [to-rev]

from-rev filters issues to lines changed since (and including) this revision
  to-rev filters issues to lines changed since (and including) this revision, requires <from-rev>

  If no revisions are given, and there are unstaged changes or untracked files, only those changes are shown
  If no revisions are given, and there are no unstaged changes or untracked files, only changes in HEAD~ are shown
  If from-rev is given and to-rev is not, only changes between from-rev and HEAD are shown.

    -d    Show debug output
      -regexp string
              Regexp to match path, line number, optional column number, and message

Other Examples

Issues between branches:

[user@host dir (feature/branch)]$ go vet |& revgrep master

Issues since last push:

[user@host dir (master)]$ go vet |& revgrep origin/master