Unexpected behavior on diff -I<regex> --name-only
- From
Johannes Altmanninger <aclopte@gmail.com>
- Date
- Dec 14, 2020, 19:00 UTC
- Message-ID
- <20201214190054.lrdllbpf6jfrz573@gmail.com>
Since v2.28.0-2-g296d4a94e7 (diff: add -I<regex> that ignores matching changes) diff -I<regex> can be used to suppress hunks of only matching lines. This interacts in a surprising way with --name-only, which lists all changed files, regardless of whether they are filtered out by -I<regex>:
git diff HEAD~ -I '' # always empty git diff HEAD~ -I '' --name-only # not empty, "-I" does nothing
It could be nice to only show names of files with matching hunks (or reject this combination of options?).