diffHighlighter: Empty diffs and mode-changes

When there is no diff to display (i.e. empty-file mode-changes, deletion
or creation) we don't draw a diff-box (div) but just list the filename.

Also fixes a bug with mode-changes not displaying new-mode.
This commit is contained in:
Johannes Gilger
2009-02-07 16:31:03 +01:00
parent f23b3c498f
commit 308a5af02f
+20 -15
View File
@@ -67,10 +67,12 @@ var highlightDiff = function(diff, element, callbacks) {
return; // so printing the filename in the file-list is enough
}
finalContent += '<div class="file" id="file_index_' + (file_index - 1) + '">' +
'<div class="fileHeader">' + title + '</div>';
if (diffContent != "" || binary) {
finalContent += '<div class="file" id="file_index_' + (file_index - 1) + '">' +
'<div class="fileHeader">' + title + '</div>';
}
if (!binary) {
if (!binary && (diffContent != "")) {
finalContent += '<div class="diffContent">' +
'<div class="lineno">' + line1 + "</div>" +
'<div class="lineno">' + line2 + "</div>" +
@@ -86,7 +88,8 @@ var highlightDiff = function(diff, element, callbacks) {
}
}
finalContent += '</div>';
if (diffContent != "" || binary)
finalContent += '</div>';
line1 = "";
line2 = "";
@@ -120,8 +123,21 @@ var highlightDiff = function(diff, element, callbacks) {
if (firstChar == "n") {
if (l.match(/^new file mode .*$/))
startname = "/dev/null";
if (match = l.match(/^new mode (.*)$/)) {
mode_change = true;
new_mode = match[1];
}
continue;
}
if (firstChar == "o") {
if (match = l.match(/^old mode (.*)$/)) {
mode_change = true;
old_mode = match[1];
}
continue;
}
if (firstChar == "d") {
if (l.match(/^deleted file mode .*$/))
endname = "/dev/null";
@@ -163,17 +179,6 @@ var highlightDiff = function(diff, element, callbacks) {
}
}
if (match = l.match(/^old mode (.*)$/)) {
mode_change = true;
old_mode = match[1];
}
if (match = l.match(/^new mode (.*)$/)) {
mode_change = true;
new_mode = match[1];
}
// Finish the header
if (firstChar == "@")
header = false;