Jonathan Tan <jonathanta...@google.com> writes:

> -     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;

This makes sense, but "--diff-algorithm=patience" would want to do
the same, I suspect, so the loop would want to become a little
helper function "clear_patience_anchors(options)" or something like
that.

> diff --git a/t/t4064-diff-anchored.sh b/t/t4064-diff-anchored.sh
> new file mode 100755
> index 000000000..b3f510f04
> --- /dev/null
> +++ b/t/t4064-diff-anchored.sh
> @@ -0,0 +1,94 @@
> +#!/bin/sh
> +
> +test_description='anchored diff algorithm'
> +
> +. ./test-lib.sh
> +
> +test_expect_success '--anchored' '
> +     printf "a\nb\nc\n" >pre &&
> +     printf "c\na\nb\n" >post &&

This may be too little to matter, but I'd find

        printf "%s\n" a b c >pre

vastly easier to read.  Or perhaps just use

        test_write_lines a b c >pre

Reply via email to