xdiff: add 'minimal' to XDF_DIFF_ALGORITHM_MASK
The XDF_DIFF_ALGORITHM_MASK bit mask only includes bits for the patience and histogram diffs, not for the minimal one. This means that when reseting the diff algorithm to the default one, one needs to separately clear the bit for the minimal diff. There are places in the code that fail to do that: merge-ort.c and builtin/merge-file.c. Add the XDF_NEED_MINIMAL bit to the bit mask, and remove the separate clearing of this bit in the places where it hasn't been forgotten. Signed-off-by: Antonin Delpeuch <antonin@delpeuch.eu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Antonin Delpeuch committed
Nov 17, 2025 at 08:04 UTC
881793c4f71c84e70af256c5721475c7c088b3f7
3 files changed
+1
-3
diff.c
-1
@@ -3527,7 +3527,6 @@ static int set_diff_algorithm(struct diff_options *opts,
3527
return -1;
3528
3529
/* clear out previous settings */
3530
- DIFF_XDL_CLR(opts, NEED_MINIMAL);
3530
opts->xdl_opts &= ~XDF_DIFF_ALGORITHM_MASK;
3531
opts->xdl_opts |= value;
3532
merge-ort.c
-1
@@ -5496,7 +5496,6 @@ int parse_merge_opt(struct merge_options *opt, const char *s)
5496
if (value < 0)
5497
return -1;
5498
/* clear out previous settings */
5499
- DIFF_XDL_CLR(opt, NEED_MINIMAL);
5499
opt->xdl_opts &= ~XDF_DIFF_ALGORITHM_MASK;
5500
opt->xdl_opts |= value;
5501
}
xdiff/xdiff.h
+1
-1
@@ -43,7 +43,7 @@ extern "C" {
43
44
#define XDF_PATIENCE_DIFF (1 << 14)
45
#define XDF_HISTOGRAM_DIFF (1 << 15)
46
-#define XDF_DIFF_ALGORITHM_MASK (XDF_PATIENCE_DIFF | XDF_HISTOGRAM_DIFF)
46
+#define XDF_DIFF_ALGORITHM_MASK (XDF_PATIENCE_DIFF | XDF_HISTOGRAM_DIFF | XDF_NEED_MINIMAL)
47
#define XDF_DIFF_ALG(x) ((x) & XDF_DIFF_ALGORITHM_MASK)
48
49
#define XDF_INDENT_HEURISTIC (1 << 23)