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);
+ textconv_one = get_textconv(o->repo->index, p->one);
+ textconv_two = get_textconv(o->repo->index, p->two);
}
/*
if (textconv_one == textconv_two && diff_unmodified_pair(p))
return 0;
- mf1.size = fill_textconv(textconv_one, p->one, &mf1.ptr);
- mf2.size = fill_textconv(textconv_two, p->two, &mf2.ptr);
+ mf1.size = fill_textconv(o->repo, textconv_one, p->one, &mf1.ptr);
+ mf2.size = fill_textconv(o->repo, textconv_two, p->two, &mf2.ptr);
ret = fn(DIFF_FILE_VALID(p->one) ? &mf1 : NULL,
DIFF_FILE_VALID(p->two) ? &mf2 : NULL,
/* The POSIX.2 people are surely sick */
char errbuf[1024];
regerror(err, regex, errbuf, 1024);
- regfree(regex);
die("invalid regex: %s", errbuf);
}
}
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(®ex, needle, cflags);
regexp = ®ex;
- } 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(®ex, sb.buf, cflags);
- strbuf_release(&sb);
- regexp = ®ex;
- } 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(®ex, sb.buf, cflags);
+ strbuf_release(&sb);
+ regexp = ®ex;
+ } 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;
}