diff options
author | René Scharfe <l.s.r@web.de> | 2021-12-17 17:48:49 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-12-17 14:13:08 -0800 |
commit | 794c000267b7bd29024b56e282509a82b31e6fc8 (patch) | |
tree | b3461a00666e3b60104a5bfd0f8ea949f50beec9 /t | |
parent | Git 2.34.1 (diff) | |
download | tgif-794c000267b7bd29024b56e282509a82b31e6fc8.tar.xz |
log: let --invert-grep only invert --grep
The option --invert-grep is documented to filter out commits whose
messages match the --grep filters. However, it also affects the
header matches (--author, --committer), which is not intended.
Move the handling of that option to grep.c, as only the code there can
distinguish between matches in the header from those in the message
body. If --invert-grep is given then enable extended expressions (not
the regex type, we just need git grep's --not to work), negate the body
patterns and check if any of them match by piggy-backing on the
collect_hits mechanism of grep_source_1().
Collecting the matches in struct grep_opt is a bit iffy, but with
"last_shown" we have a precedent for writing state information to that
struct.
Reported-by: Dotan Cohen <dotancohen@gmail.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t4202-log.sh | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 7884e3d46b..765742fdbc 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -2010,4 +2010,23 @@ test_expect_success 'log --end-of-options' ' test_cmp expect actual ' +test_expect_success 'set up commits with different authors' ' + git checkout --orphan authors && + test_commit --author "Jim <jim@example.com>" jim_1 && + test_commit --author "Val <val@example.com>" val_1 && + test_commit --author "Val <val@example.com>" val_2 && + test_commit --author "Jim <jim@example.com>" jim_2 && + test_commit --author "Val <val@example.com>" val_3 && + test_commit --author "Jim <jim@example.com>" jim_3 +' + +test_expect_success 'log --invert-grep --grep --author' ' + cat >expect <<-\EOF && + val_3 + val_1 + EOF + git log --format=%s --author=Val --grep 2 --invert-grep >actual && + test_cmp expect actual +' + test_done |