]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'tb/log-G-binary'
authorJunio C Hamano <gitster@pobox.com>
Mon, 14 Jan 2019 23:29:31 +0000 (15:29 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 14 Jan 2019 23:29:31 +0000 (15:29 -0800)
"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

1  2 
diffcore-pickaxe.c

diff --combined diffcore-pickaxe.c
index ad939d2861554746a9fd52947a38943928ece552,4cea086f80e657e57ed5ccb2c5f7eeb5c6a640ab..a9c6d60df22862e47ccb7fc1c7de9ed7cc4b1236
@@@ -140,8 -140,8 +140,8 @@@ static int pickaxe_match(struct diff_fi
                return 0;
  
        if (o->flags.allow_textconv) {
 -              textconv_one = get_textconv(o->repo->index, p->one);
 -              textconv_two = get_textconv(o->repo->index, p->two);
 +              textconv_one = get_textconv(o->repo, p->one);
 +              textconv_two = get_textconv(o->repo, p->two);
        }
  
        /*
        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);