From 51478449ecff911e86436ebee04002c047ebc0e5 Mon Sep 17 00:00:00 2001 From: Johannes Gilger Date: Sat, 21 Feb 2009 23:02:14 +0100 Subject: [PATCH] diffHighlighter: Correctly match unified diff hunks Hunks in unified diffs are usually in the form of @@ -a,b +x,y @@, but sometimes the ,b (i.e. the range) can be ommitted, in which case our code didn't match the hunk-header at all, resulting in line-numbers off-by-one in commit-view. Signed-off-by: Johannes Gilger --- html/lib/diffHighlighter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/lib/diffHighlighter.js b/html/lib/diffHighlighter.js index cc06fc8..0ced30f 100644 --- a/html/lib/diffHighlighter.js +++ b/html/lib/diffHighlighter.js @@ -203,7 +203,7 @@ var highlightDiff = function(diff, element, callbacks) { header = false; } - if (m = l.match(/@@ \-([0-9]+),\d+ \+(\d+),\d+ @@/)) + if (m = l.match(/@@ \-([0-9]+),?\d* \+(\d+),?\d* @@/)) { hunk_start_line_1 = parseInt(m[1]) - 1; hunk_start_line_2 = parseInt(m[2]) - 1;