From: Johannes Schindelin <johannes.schindelin@xxxxxx> 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` 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. Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx> --- diff.c | 8 +++----- t/t4202-log.sh | 8 ++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/diff.c b/diff.c index c862771a589..fc1151b9c73 100644 --- a/diff.c +++ b/diff.c @@ -4821,17 +4821,15 @@ static int diff_opt_diff_filter(const struct option *option, prepare_filter_bits(); /* - * If there is a negation e.g. 'd' in the input, and we haven't + * If the input starts with a negation e.g. 'd', and we haven't * initialized the filter field with another --diff-filter, start * from full set of bits, except for AON. */ if (!opt->filter) { - for (i = 0; (optch = optarg[i]) != '\0'; i++) { - if (optch < 'a' || 'z' < optch) - continue; + optch = optarg[0]; + if (optch >= 'a' && 'z' >= optch) { opt->filter = (1 << (ARRAY_SIZE(diff_status_letters) - 1)) - 1; opt->filter &= ~filter_bit[DIFF_STATUS_FILTER_AON]; - break; } } diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 50495598619..28f727937dd 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -142,6 +142,14 @@ test_expect_success 'diff-filter=R' ' ' +test_expect_success 'diff-filter=Ra' ' + + git log -M --pretty="format:%s" --diff-filter=R HEAD >expect && + git log -M --pretty="format:%s" --diff-filter=Ra HEAD >actual && + test_cmp expect actual + +' + test_expect_success 'diff-filter=C' ' git log -C -C --pretty="format:%s" --diff-filter=C HEAD >actual && -- gitgitgadget