]> git.ipfire.org Git - thirdparty/git.git/commit
xdiff: disable cleanup_records heuristic with --minimal
authorNiels Glodny <n.glodny@campus.lmu.de>
Tue, 29 Apr 2025 14:09:49 +0000 (16:09 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 29 Apr 2025 19:46:58 +0000 (12:46 -0700)
commit03f2915541a4923c5733e505a42e77031eb9494c
tree057bd2a3298a0e178944fe2a8b558f327b9039b1
parentf65182a99e545d2f2bc22e6c1c2da192133b16a3
xdiff: disable cleanup_records heuristic with --minimal

The cleanup_records function marks some lines as changed before running
the actual diff algorithm. For most lines, this is a good performance
optimization, but it also marks lines that are surrounded by many
changed lines as changed as well. This can cause redundant changes and
longer-than-necessary diffs.

Whether this results in better-looking diffs is subjective. However, the
--minimal flag explicitly requests the shortest possible diff.

The change results in shorter diffs in about 1.3% of all diffs in Git's
history. Performance wise, I have measured the impact on
"git log -p -3000 --minimal > /dev/null". With this change, I get
  Time (mean ± σ): 2.363 s ±  0.023 s (25 runs)
and without this patch I measured
  Time (mean ± σ): 2.362 s ±  0.035 s (25 runs).
As the difference is well within the margin of error, this does not seem
to have an impact on performance.

Signed-off-by: Niels Glodny <n.glodny@campus.lmu.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/meson.build
t/t4071-diff-minimal.sh [new file with mode: 0755]
xdiff/xprepare.c