Skip to content

Commit 973ac31

Browse files
committed
Fix display of empty files in the Stage view
As JS considers empty strings and "nil"/undefined objects the same, we'd end up considering empty files as maybe binary, which isn't true.
1 parent cec4600 commit 973ac31

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Classes/git/PBGitIndex.m

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,9 +559,6 @@ - (NSString *)diffForFile:(PBChangedFile *)file staged:(BOOL)staged contextLines
559559
NSString *contents = [NSString stringWithContentsOfURL:fileURL
560560
usedEncoding:&encoding
561561
error:&error];
562-
if (error)
563-
return nil;
564-
565562
return contents;
566563
}
567564

Resources/html/views/commit/commit.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ var showNewFile = function(file)
99
diff.innerHTML = "";
1010

1111
var contents = Index.diffForFile_staged_contextLines_(file, false, contextLines);
12-
if (!contents) {
12+
if (contents === undefined) {
1313
notify("Can not display changes (Binary file?)", -1);
1414
return;
15+
} else if (contents.length == 0) {
16+
notify("Empty file", 1);
17+
return;
1518
}
1619

1720
var pre = document.createElement("pre");

0 commit comments

Comments
 (0)