]> Lady’s Gitweb - Gitweb/commit
gitweb: Highlight interesting parts of diff
authorMichał Kiedrowicz <redacted>
Wed, 11 Apr 2012 21:18:43 +0000 (23:18 +0200)
committerLady <redacted>
Mon, 6 Apr 2026 04:51:32 +0000 (00:51 -0400)
commit20b7839f0cd45d4c205e8d6934370c8354078153e2b2c86430ae163434edeb61
tree9ee32ebaa427a8e86017494a02c448d22734391b350a9a46328228d065509473
parent2ccb4d626f1a8d6c0e15e0c0253e100178d1fc7de65b383e9e090d2f20978bea
gitweb: Highlight interesting parts of diff

Reading diff output is sometimes very hard, even if it's colored,
especially if lines differ only in few characters.  This is often true
when a commit fixes a typo or renames some variables or functions.

This commit teaches gitweb to highlight characters that are different
between old and new line with a light green/red background.  This should
work in the similar manner as in Trac or GitHub.

The algorithm that compares lines is based on contrib/diff-highlight.
Basically, it works by determining common prefix/suffix of corresponding
lines and highlightning only the middle part of lines.  For more
information, see contrib/diff-highlight/README.

Combined diffs are not supported but a following commit will change it.

Since we need to pass esc_html()'ed or esc_html_hl_regions()'ed lines to
format_diff_lines(), so it was taught to accept preformatted lines
passed as a reference.

Signed-off-by: Michał Kiedrowicz <redacted>
Acked-by: Jakub Narębski <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl
static/gitweb.css
This page took 0.217448 seconds and 4 git commands to generate.