Also, these upper-case letters can be downcased to exclude.
E.g. --diff-filter=ad
excludes added and deleted paths.
In your case, git diff --diff-filter=ad
would work, but make sure to not use lower and upper letters in the same filter, unless you have Git 2.36 (Q2 2022).
"git diff --diff-filter=aR
"(man) is now parsed correctly.
See commit 75408ca, commit 4d4d4ea, commit d843e31 (28 Jan 2022) by Johannes Schindelin (dscho
).
(Merged by Junio C Hamano -- gitster
-- in commit 9a16099, 16 Feb 2022)
diff-filter
: be more careful when looking for negative bits
Signed-off-by: Johannes Schindelin
The --diff-filter=<bits>
option allows to filter the diff by certain criteria, for example R
to only show renamed files.
It also supports negating a filter via a down-cased letter, i.e.
r
to show everything but renamed files.
However, the code is a bit overzealous when trying to figure out whether git diff
(man) should start with all diff-filters turned on because the user provided a lower-case letter: if the --diff-filter
argument starts with an upper-case letter, we must not start with all bits turned on.
Even worse, it is possible to specify the diff filters in multiple, separate options, e.g. --diff-filter=AM [...] --diff-filter=m
.
Let's accumulate the include/exclude filters independently, and only special-case the "only exclude filters were specified" case after parsing the options altogether.