t4014: more tests about appending s-o-b lines
[gitweb.git] / diffcore-pickaxe.c
index 380a837b5b136ae88d374ae8a7326c87597107fc..a20937635435f6672f801454c992cbeeb8d17a1a 100644 (file)
@@ -104,10 +104,10 @@ static int diff_grep(struct diff_filepair *p, struct diff_options *o,
                if (!mf2.ptr)
                        return 0; /* ignore unmerged */
                /* created "two" -- does it have what we are looking for? */
-               hit = !regexec(regexp, p->two->data, 1, &regmatch, 0);
+               hit = !regexec(regexp, mf2.ptr, 1, &regmatch, 0);
        } else if (!mf2.ptr) {
                /* removed "one" -- did it have what we are looking for? */
-               hit = !regexec(regexp, p->one->data, 1, &regmatch, 0);
+               hit = !regexec(regexp, mf1.ptr, 1, &regmatch, 0);
        } else {
                /*
                 * We have both sides; need to run textual diff and see if
@@ -138,8 +138,12 @@ static void diffcore_pickaxe_grep(struct diff_options *o)
 {
        int err;
        regex_t regex;
+       int cflags = REG_EXTENDED | REG_NEWLINE;
 
-       err = regcomp(&regex, o->pickaxe, REG_EXTENDED | REG_NEWLINE);
+       if (DIFF_OPT_TST(o, PICKAXE_IGNORE_CASE))
+               cflags |= REG_ICASE;
+
+       err = regcomp(&regex, o->pickaxe, cflags);
        if (err) {
                char errbuf[1024];
                regerror(err, &regex, errbuf, 1024);
@@ -237,7 +241,8 @@ static void diffcore_pickaxe_count(struct diff_options *o)
                }
                regexp = &regex;
        } else {
-               kws = kwsalloc(NULL);
+               kws = kwsalloc(DIFF_OPT_TST(o, PICKAXE_IGNORE_CASE)
+                              ? tolower_trans_tbl : NULL);
                kwsincr(kws, needle, len);
                kwsprep(kws);
        }