Skip to content

Commit

Permalink
merge-recursive: fix parsing of "diff-algorithm" option
Browse files Browse the repository at this point in the history
The "diff-algorithm" option to the recursive merge strategy takes the
name of the algorithm as an option, but it uses strcmp on the option
string to check if it starts with "diff-algorithm=", meaning that this
options cannot actually be used.

Fix this by switching to prefixcmp.  At the same time, clarify the
following line by using strlen instead of a hard-coded length, which
also makes it consistent with nearby code.

Reported-by: Luke Noel-Storr <luke.noel-storr@integrate.co.uk>
Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
  • Loading branch information
John Keeping authored and Jonathan Nieder committed Sep 26, 2013
1 parent 0895c6d commit 6562928
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions merge-recursive.c
Original file line number Diff line number Diff line change
Expand Up @@ -2068,8 +2068,8 @@ int parse_merge_opt(struct merge_options *o, const char *s)
o->xdl_opts = DIFF_WITH_ALG(o, PATIENCE_DIFF);
else if (!strcmp(s, "histogram"))
o->xdl_opts = DIFF_WITH_ALG(o, HISTOGRAM_DIFF);
else if (!strcmp(s, "diff-algorithm=")) {
long value = parse_algorithm_value(s+15);
else if (!prefixcmp(s, "diff-algorithm=")) {
long value = parse_algorithm_value(s + strlen("diff-algorithm="));
if (value < 0)
return -1;
/* clear out previous settings */
Expand Down

0 comments on commit 6562928

Please sign in to comment.