MCPcopy Create free account
hub / github.com/git/git / diff_grep

Function diff_grep

diffcore-pickaxe.c:43–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43static int diff_grep(mmfile_t *one, mmfile_t *two,
44 struct diff_options *o,
45 regex_t *regexp, kwset_t kws UNUSED)
46{
47 struct diffgrep_cb ecbdata;
48 xpparam_t xpp;
49 xdemitconf_t xecfg;
50 int ret;
51
52 /*
53 * We have both sides; need to run textual diff and see if
54 * the pattern appears on added/deleted lines.
55 */
56 memset(&xpp, 0, sizeof(xpp));
57 memset(&xecfg, 0, sizeof(xecfg));
58 ecbdata.regexp = regexp;
59 ecbdata.hit = 0;
60 xecfg.flags = XDL_EMIT_NO_HUNK_HDR;
61 xecfg.ctxlen = o->context;
62 xecfg.interhunkctxlen = o->interhunkcontext;
63
64 /*
65 * An xdiff error might be our "data->hit" from above. See the
66 * comment for xdiff_emit_line_fn in xdiff-interface.h
67 */
68 ret = xdi_diff_outf(one, two, NULL, diffgrep_consume,
69 &ecbdata, &xpp, &xecfg);
70 if (ecbdata.hit)
71 return 1;
72 if (ret)
73 return ret;
74 return 0;
75}
76
77static unsigned int contains(mmfile_t *mf, regex_t *regexp, kwset_t kws,
78 unsigned int limit)

Callers

nothing calls this directly

Calls 1

xdi_diff_outfFunction · 0.85

Tested by

no test coverage detected