aboutsummaryrefslogtreecommitdiff
path: root/contrib/diff-highlight/README
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2012-02-13 17:36:36 -0500
committerJunio C Hamano <gitster@pobox.com>2012-02-13 15:57:06 -0800
commit34d9819e0a387be6d49cffe67458036450d6d0d5 (patch)
treed11fc079858328ca3ec4abe51f7a7cd48211c4b0 /contrib/diff-highlight/README
parent6463fd7ed189f4100e1102062f29b969384f1436 (diff)
downloadgit-34d9819e0a387be6d49cffe67458036450d6d0d5.tar.gz
git-34d9819e0a387be6d49cffe67458036450d6d0d5.tar.xz
diff-highlight: match multi-line hunks
Currently we only bother highlighting single-line hunks. The rationale was that the purpose of highlighting is to point out small changes between two similar lines that are otherwise hard to see. However, that meant we missed similar cases where two lines were changed together, like: -foo(buf); -bar(buf); +foo(obj->buf); +bar(obj->buf); Each of those changes is simple, and would benefit from highlighting (the "obj->" parts in this case). This patch considers whole hunks at a time. For now, we consider only the case where the hunk has the same number of removed and added lines, and assume that the lines from each segment correspond one-to-one. While this is just a heuristic, in practice it seems to generate sensible results (especially because we now omit highlighting on completely-changed lines, so when our heuristic is wrong, we tend to avoid highlighting at all). Based on an original idea and implementation by MichaƂ Kiedrowicz. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/diff-highlight/README')
-rw-r--r--contrib/diff-highlight/README16
1 files changed, 9 insertions, 7 deletions
diff --git a/contrib/diff-highlight/README b/contrib/diff-highlight/README
index 1b7b6df8e..4a5857977 100644
--- a/contrib/diff-highlight/README
+++ b/contrib/diff-highlight/README
@@ -14,13 +14,15 @@ Instead, this script post-processes the line-oriented diff, finds pairs
of lines, and highlights the differing segments. It's currently very
simple and stupid about doing these tasks. In particular:
- 1. It will only highlight a pair of lines if they are the only two
- lines in a hunk. It could instead try to match up "before" and
- "after" lines for a given hunk into pairs of similar lines.
- However, this may end up visually distracting, as the paired
- lines would have other highlighted lines in between them. And in
- practice, the lines which most need attention called to their
- small, hard-to-see changes are touching only a single line.
+ 1. It will only highlight hunks in which the number of removed and
+ added lines is the same, and it will pair lines within the hunk by
+ position (so the first removed line is compared to the first added
+ line, and so forth). This is simple and tends to work well in
+ practice. More complex changes don't highlight well, so we tend to
+ exclude them due to the "same number of removed and added lines"
+ restriction. Or even if we do try to highlight them, they end up
+ not highlighting because of our "don't highlight if the whole line
+ would be highlighted" rule.
2. It will find the common prefix and suffix of two lines, and
consider everything in the middle to be "different". It could