diff: Introduce --diff-algorithm command line option
Since command line options have higher priority than config file variables and taking previous commit into account, we need a way how to specify myers algorithm on command line. However, inventing `--myers` is not the right answer. We need far more general option, and that is `--diff-algorithm`. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
07ab4dec80
commit
07924d4d50
12
diff.c
12
diff.c
@ -144,7 +144,7 @@ static int git_config_rename(const char *var, const char *value)
|
||||
return git_config_bool(var,value) ? DIFF_DETECT_RENAME : 0;
|
||||
}
|
||||
|
||||
static long parse_algorithm_value(const char *value)
|
||||
long parse_algorithm_value(const char *value)
|
||||
{
|
||||
if (!value)
|
||||
return -1;
|
||||
@ -3634,6 +3634,16 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
|
||||
options->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);
|
||||
else if (!strcmp(arg, "--histogram"))
|
||||
options->xdl_opts = DIFF_WITH_ALG(options, HISTOGRAM_DIFF);
|
||||
else if (!prefixcmp(arg, "--diff-algorithm=")) {
|
||||
long value = parse_algorithm_value(arg+17);
|
||||
if (value < 0)
|
||||
return error("option diff-algorithm accepts \"myers\", "
|
||||
"\"minimal\", \"patience\" and \"histogram\"");
|
||||
/* clear out previous settings */
|
||||
DIFF_XDL_CLR(options, NEED_MINIMAL);
|
||||
options->xdl_opts &= ~XDF_DIFF_ALGORITHM_MASK;
|
||||
options->xdl_opts |= value;
|
||||
}
|
||||
|
||||
/* flags options */
|
||||
else if (!strcmp(arg, "--binary")) {
|
||||
|
||||
Reference in New Issue
Block a user