]> Kevux Git Server - rit/commit
xdiff: add macros DISCARD(0), KEEP(1), INVESTIGATE(2) in xprepare.c
authorEzekiel Newren <ezekielnewren@gmail.com>
Fri, 26 Sep 2025 22:41:58 +0000 (22:41 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 3 Oct 2025 17:19:40 +0000 (10:19 -0700)
commite385e1b7d2d7f531a0006131e7f1d974de351df5
tree17a83cb37af1ffcea91a5dd7272a1761733a7948
parentb7de64a6d6f58953a0c1dc7ff34f7080b3e38b37
xdiff: add macros DISCARD(0), KEEP(1), INVESTIGATE(2) in xprepare.c

This commit is refactor-only; no behavior is changed. A future commit
will use bool literals for changed[i].

The functions xdl_clean_mmatch() and xdl_cleanup_records() will be
cleaned up more in a future patch series. The changes to
xdl_cleanup_records(), in this patch, are just to make it clear why
`char rchg` is refactored to `bool changed`.

Rename dis* to action* and replace literal numericals with macros.
The old names came from when dis* (which I think was short for discard)
was treated like a boolean, but over time it grew into a ternary state
machine. The result was confusing because dis* and rchg* both used 0/1
values with different meanings.

The new names and macros make the states explicit. nm is short for
number of matches, and mlim is a heuristic limit:

  nm == 0       -> action[i] = DISCARD     -> changed[i] = true
  0 < nm < mlim -> action[i] = KEEP        -> changed[i] = false
  nm >= mlim    -> action[i] = INVESTIGATE -> changed[i] = xdl_clean_mmatch()

When need_min is true, only DISCARD and KEEP occur because the limit
is effectively infinite.

Best-viewed-with: --color-words
Signed-off-by: Ezekiel Newren <ezekielnewren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
xdiff/xprepare.c