From b44b0df75a3be7fab3167ed2a91651c2fe62d7e0 Mon Sep 17 00:00:00 2001 From: Pieter de Bie Date: Sun, 25 Jan 2009 21:45:28 +0000 Subject: [PATCH] DiffHighlighter: Properly show binary changes Binary changes don't have a +++ / --- line, just like a 100% rename doesn't show any changes. We work around this in much the same way -- by reading the filenames for that specific case. --- html/lib/diffHighlighter.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/html/lib/diffHighlighter.js b/html/lib/diffHighlighter.js index b604e11..47fb35a 100644 --- a/html/lib/diffHighlighter.js +++ b/html/lib/diffHighlighter.js @@ -63,7 +63,7 @@ var highlightDiff = function(diff, element, callbacks) { } else { if (callbacks["binaryFile"]) - finalContent += callbacks["binaryFile"](filename); + finalContent += callbacks["binaryFile"](startname); else finalContent += "
Binary file differs
"; } @@ -115,10 +115,17 @@ var highlightDiff = function(diff, element, callbacks) { } continue; } - if (firstChar == "B") // "Binary files" + if (firstChar == "B") // "Binary files .. and .. differ" { binary = true; - Controller.log_("Binary file"); + // We might not have a diff from the binary file if it's new. + // So, we use a regex to figure that out + + if (match = l.match(/^Binary files (a\/)?(.*) and (b\/)(.*) differ$/)) + { + startname = match[2]; + endname = match[4]; + } } // Finish the header