]> git.ipfire.org Git - thirdparty/git.git/blobdiff - diffcore-pickaxe.c
Sync with 2.16.6
[thirdparty/git.git] / diffcore-pickaxe.c
index 9476bd21081f456be6ae6412ea591e11dde50686..239ce5122b3a45bec211e0c20113385c0e37805d 100644 (file)
@@ -124,13 +124,20 @@ static int pickaxe_match(struct diff_filepair *p, struct diff_options *o,
        mmfile_t mf1, mf2;
        int ret;
 
-       if (!o->pickaxe[0])
-               return 0;
-
        /* ignore unmerged */
        if (!DIFF_FILE_VALID(p->one) && !DIFF_FILE_VALID(p->two))
                return 0;
 
+       if (o->objfind) {
+               return  (DIFF_FILE_VALID(p->one) &&
+                        oidset_contains(o->objfind, &p->one->oid)) ||
+                       (DIFF_FILE_VALID(p->two) &&
+                        oidset_contains(o->objfind, &p->two->oid));
+       }
+
+       if (!o->pickaxe[0])
+               return 0;
+
        if (o->flags.allow_textconv) {
                textconv_one = get_textconv(p->one);
                textconv_two = get_textconv(p->two);
@@ -222,33 +229,34 @@ void diffcore_pickaxe(struct diff_options *o)
 
        if (opts & (DIFF_PICKAXE_REGEX | DIFF_PICKAXE_KIND_G)) {
                int cflags = REG_EXTENDED | REG_NEWLINE;
-               if (o->flags.pickaxe_ignore_case)
+               if (o->pickaxe_opts & DIFF_PICKAXE_IGNORE_CASE)
                        cflags |= REG_ICASE;
                regcomp_or_die(&regex, needle, cflags);
                regexp = &regex;
-       } else if (o->flags.pickaxe_ignore_case &&
-                  has_non_ascii(needle)) {
-               struct strbuf sb = STRBUF_INIT;
-               int cflags = REG_NEWLINE | REG_ICASE;
-
-               basic_regex_quote_buf(&sb, needle);
-               regcomp_or_die(&regex, sb.buf, cflags);
-               strbuf_release(&sb);
-               regexp = &regex;
-       } else {
-               kws = kwsalloc(o->flags.pickaxe_ignore_case
-                              ? tolower_trans_tbl : NULL);
-               kwsincr(kws, needle, strlen(needle));
-               kwsprep(kws);
+       } else if (opts & DIFF_PICKAXE_KIND_S) {
+               if (o->pickaxe_opts & DIFF_PICKAXE_IGNORE_CASE &&
+                   has_non_ascii(needle)) {
+                       struct strbuf sb = STRBUF_INIT;
+                       int cflags = REG_NEWLINE | REG_ICASE;
+
+                       basic_regex_quote_buf(&sb, needle);
+                       regcomp_or_die(&regex, sb.buf, cflags);
+                       strbuf_release(&sb);
+                       regexp = &regex;
+               } else {
+                       kws = kwsalloc(o->pickaxe_opts & DIFF_PICKAXE_IGNORE_CASE
+                                      ? tolower_trans_tbl : NULL);
+                       kwsincr(kws, needle, strlen(needle));
+                       kwsprep(kws);
+               }
        }
 
-       /* Might want to warn when both S and G are on; I don't care... */
        pickaxe(&diff_queued_diff, o, regexp, kws,
                (opts & DIFF_PICKAXE_KIND_G) ? diff_grep : has_changes);
 
        if (regexp)
                regfree(regexp);
-       else
+       if (kws)
                kwsfree(kws);
        return;
 }