Skip to content

Commit 0895c6d

Browse files
johnkeepinggitster
authored andcommitted
diff: allow unstuck arguments with --diff-algorithm
The argument to --diff-algorithm is mandatory, so there is no reason to require the argument to be stuck to the option with '='. Change this for consistency with other Git commands. Note that this does not change the handling of diff-algorithm in merge-recursive.c since the primary interface to that is via the -X option to 'git merge' where the unstuck form does not make sense. Signed-off-by: John Keeping <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4db4f0f commit 0895c6d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

diff.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3634,15 +3634,16 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
36343634
options->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);
36353635
else if (!strcmp(arg, "--histogram"))
36363636
options->xdl_opts = DIFF_WITH_ALG(options, HISTOGRAM_DIFF);
3637-
else if (!prefixcmp(arg, "--diff-algorithm=")) {
3638-
long value = parse_algorithm_value(arg+17);
3637+
else if ((argcount = parse_long_opt("diff-algorithm", av, &optarg))) {
3638+
long value = parse_algorithm_value(optarg);
36393639
if (value < 0)
36403640
return error("option diff-algorithm accepts \"myers\", "
36413641
"\"minimal\", \"patience\" and \"histogram\"");
36423642
/* clear out previous settings */
36433643
DIFF_XDL_CLR(options, NEED_MINIMAL);
36443644
options->xdl_opts &= ~XDF_DIFF_ALGORITHM_MASK;
36453645
options->xdl_opts |= value;
3646+
return argcount;
36463647
}
36473648

36483649
/* flags options */

0 commit comments

Comments
 (0)