Merge branch 'ab/pickaxe-pcre2'
Rewrite the backend for "diff -G/-S" to use pcre2 engine when available. * ab/pickaxe-pcre2: (22 commits) xdiff-interface: replace discard_hunk_line() with a flag xdiff users: use designated initializers for out_line pickaxe -G: don't special-case create/delete pickaxe -G: terminate early on matching lines xdiff-interface: allow early return from xdiff_emit_line_fn xdiff-interface: prepare for allowing early return pickaxe -S: slightly optimize contains() pickaxe: rename variables in has_changes() for brevity pickaxe -S: support content with NULs under --pickaxe-regex pickaxe: assert that we must have a needle under -G or -S pickaxe: refactor function selection in diffcore-pickaxe() perf: add performance test for pickaxe pickaxe/style: consolidate declarations and assignments diff.h: move pickaxe fields together again pickaxe: die when --find-object and --pickaxe-all are combined pickaxe: die when -G and --pickaxe-regex are combined pickaxe tests: add missing test for --no-pickaxe-regex being an error pickaxe tests: test for -G, -S and --find-object incompatibility pickaxe tests: add test for "log -S" not being a regex pickaxe tests: add test for diffgrep_consume() internals ...
This commit is contained in:
@ -31,29 +31,36 @@ static int xdiff_out_hunk(void *priv_,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void consume_one(void *priv_, char *s, unsigned long size)
|
||||
static int consume_one(void *priv_, char *s, unsigned long size)
|
||||
{
|
||||
struct xdiff_emit_state *priv = priv_;
|
||||
char *ep;
|
||||
while (size) {
|
||||
unsigned long this_size;
|
||||
int ret;
|
||||
ep = memchr(s, '\n', size);
|
||||
this_size = (ep == NULL) ? size : (ep - s + 1);
|
||||
priv->line_fn(priv->consume_callback_data, s, this_size);
|
||||
ret = priv->line_fn(priv->consume_callback_data, s, this_size);
|
||||
if (ret)
|
||||
return ret;
|
||||
size -= this_size;
|
||||
s += this_size;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xdiff_outf(void *priv_, mmbuffer_t *mb, int nbuf)
|
||||
{
|
||||
struct xdiff_emit_state *priv = priv_;
|
||||
int i;
|
||||
int stop = 0;
|
||||
|
||||
if (!priv->line_fn)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < nbuf; i++) {
|
||||
if (stop)
|
||||
return 1;
|
||||
if (mb[i].ptr[mb[i].size-1] != '\n') {
|
||||
/* Incomplete line */
|
||||
strbuf_add(&priv->remainder, mb[i].ptr, mb[i].size);
|
||||
@ -62,17 +69,21 @@ static int xdiff_outf(void *priv_, mmbuffer_t *mb, int nbuf)
|
||||
|
||||
/* we have a complete line */
|
||||
if (!priv->remainder.len) {
|
||||
consume_one(priv, mb[i].ptr, mb[i].size);
|
||||
stop = consume_one(priv, mb[i].ptr, mb[i].size);
|
||||
continue;
|
||||
}
|
||||
strbuf_add(&priv->remainder, mb[i].ptr, mb[i].size);
|
||||
consume_one(priv, priv->remainder.buf, priv->remainder.len);
|
||||
stop = consume_one(priv, priv->remainder.buf, priv->remainder.len);
|
||||
strbuf_reset(&priv->remainder);
|
||||
}
|
||||
if (stop)
|
||||
return -1;
|
||||
if (priv->remainder.len) {
|
||||
consume_one(priv, priv->remainder.buf, priv->remainder.len);
|
||||
stop = consume_one(priv, priv->remainder.buf, priv->remainder.len);
|
||||
strbuf_reset(&priv->remainder);
|
||||
}
|
||||
if (stop)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -115,12 +126,6 @@ int xdi_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdemitconf_t co
|
||||
return xdl_diff(&a, &b, xpp, xecfg, xecb);
|
||||
}
|
||||
|
||||
void discard_hunk_line(void *priv,
|
||||
long ob, long on, long nb, long nn,
|
||||
const char *func, long funclen)
|
||||
{
|
||||
}
|
||||
|
||||
int xdi_diff_outf(mmfile_t *mf1, mmfile_t *mf2,
|
||||
xdiff_emit_hunk_fn hunk_fn,
|
||||
xdiff_emit_line_fn line_fn,
|
||||
|
||||
Reference in New Issue
Block a user