Merge branch 'jt/diff-anchored-patience'
"git diff" learned a variant of the "--patience" algorithm, to which the user can specify which 'unique' line to be used as anchoring points. * jt/diff-anchored-patience: diff: support anchoring line(s)
This commit is contained in:
22
diff.c
22
diff.c
@ -3210,6 +3210,8 @@ static void builtin_diff(const char *name_a,
|
||||
ecbdata.opt = o;
|
||||
ecbdata.header = header.len ? &header : NULL;
|
||||
xpp.flags = o->xdl_opts;
|
||||
xpp.anchors = o->anchors;
|
||||
xpp.anchors_nr = o->anchors_nr;
|
||||
xecfg.ctxlen = o->context;
|
||||
xecfg.interhunkctxlen = o->interhunkcontext;
|
||||
xecfg.flags = XDL_EMIT_FUNCNAMES;
|
||||
@ -3302,6 +3304,8 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
|
||||
memset(&xpp, 0, sizeof(xpp));
|
||||
memset(&xecfg, 0, sizeof(xecfg));
|
||||
xpp.flags = o->xdl_opts;
|
||||
xpp.anchors = o->anchors;
|
||||
xpp.anchors_nr = o->anchors_nr;
|
||||
xecfg.ctxlen = o->context;
|
||||
xecfg.interhunkctxlen = o->interhunkcontext;
|
||||
if (xdi_diff_outf(&mf1, &mf2, diffstat_consume, diffstat,
|
||||
@ -4594,9 +4598,18 @@ int diff_opt_parse(struct diff_options *options,
|
||||
DIFF_XDL_SET(options, INDENT_HEURISTIC);
|
||||
else if (!strcmp(arg, "--no-indent-heuristic"))
|
||||
DIFF_XDL_CLR(options, INDENT_HEURISTIC);
|
||||
else if (!strcmp(arg, "--patience"))
|
||||
else if (!strcmp(arg, "--patience")) {
|
||||
int i;
|
||||
options->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);
|
||||
else if (!strcmp(arg, "--histogram"))
|
||||
/*
|
||||
* Both --patience and --anchored use PATIENCE_DIFF
|
||||
* internally, so remove any anchors previously
|
||||
* specified.
|
||||
*/
|
||||
for (i = 0; i < options->anchors_nr; i++)
|
||||
free(options->anchors[i]);
|
||||
options->anchors_nr = 0;
|
||||
} else if (!strcmp(arg, "--histogram"))
|
||||
options->xdl_opts = DIFF_WITH_ALG(options, HISTOGRAM_DIFF);
|
||||
else if ((argcount = parse_long_opt("diff-algorithm", av, &optarg))) {
|
||||
long value = parse_algorithm_value(optarg);
|
||||
@ -4608,6 +4621,11 @@ int diff_opt_parse(struct diff_options *options,
|
||||
options->xdl_opts &= ~XDF_DIFF_ALGORITHM_MASK;
|
||||
options->xdl_opts |= value;
|
||||
return argcount;
|
||||
} else if (skip_prefix(arg, "--anchored=", &arg)) {
|
||||
options->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);
|
||||
ALLOC_GROW(options->anchors, options->anchors_nr + 1,
|
||||
options->anchors_alloc);
|
||||
options->anchors[options->anchors_nr++] = xstrdup(arg);
|
||||
}
|
||||
|
||||
/* flags options */
|
||||
|
Reference in New Issue
Block a user