summaryrefslogtreecommitdiffstats
path: root/diffcore-pickaxe.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-01-14 15:29:31 -0800
committerJunio C Hamano <gitster@pobox.com>2019-01-14 15:29:31 -0800
commitecdc7cbbac04241f1e5a90fb1fff13cff2ed7a82 (patch)
tree865b4149a211b52800c1051950633790b7c9be26 /diffcore-pickaxe.c
parent932b867be0cec606ec7355fc25de13ace42f4c71 (diff)
parente0e7cb8080cb4a0b3a24f288bf363fe517b49790 (diff)
downloadgit-ecdc7cbbac04241f1e5a90fb1fff13cff2ed7a82.tar.gz
git-ecdc7cbbac04241f1e5a90fb1fff13cff2ed7a82.tar.xz
Merge branch 'tb/log-G-binary'
"git log -G<regex>" looked for a hunk in the "git log -p" patch output that contained a string that matches the given pattern. Optimize this code to ignore binary files, which by default will not show any hunk that would match any pattern (unless textconv or the --text option is in effect, that is). * tb/log-G-binary: log -G: ignore binary files
Diffstat (limited to 'diffcore-pickaxe.c')
-rw-r--r--diffcore-pickaxe.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
index ad939d286..a9c6d60df 100644
--- a/diffcore-pickaxe.c
+++ b/diffcore-pickaxe.c
@@ -154,6 +154,12 @@ static int pickaxe_match(struct diff_filepair *p, struct diff_options *o,
if (textconv_one == textconv_two && diff_unmodified_pair(p))
return 0;
+ if ((o->pickaxe_opts & DIFF_PICKAXE_KIND_G) &&
+ !o->flags.text &&
+ ((!textconv_one && diff_filespec_is_binary(o->repo, p->one)) ||
+ (!textconv_two && diff_filespec_is_binary(o->repo, p->two))))
+ return 0;
+
mf1.size = fill_textconv(o->repo, textconv_one, p->one, &mf1.ptr);
mf2.size = fill_textconv(o->repo, textconv_two, p->two, &mf2.ptr);