Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "Show whitespace differences" preference in commit view #205

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions PBGitIndex.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import "PBGitRepository.h"
#import "PBGitBinary.h"
#import "PBEasyPipe.h"
#import "PBGitDefaults.h"
#import "NSString_RegEx.h"
#import "PBChangedFile.h"

Expand Down Expand Up @@ -497,7 +498,10 @@ - (NSString *)diffForFile:(PBChangedFile *)file staged:(BOOL)staged contextLines
if (file.status == NEW)
return [repository outputForArguments:[NSArray arrayWithObjects:@"show", indexPath, nil]];

return [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-index", parameter, @"--cached", [self parentTree], @"--", file.path, nil]];
NSMutableArray *arguments = [NSMutableArray arrayWithObjects:@"diff-index", parameter, @"--cached", [self parentTree], @"--", file.path, nil];
if (![PBGitDefaults showWhitespaceDifferences])
[arguments insertObject:@"-w" atIndex:2];
return [repository outputInWorkdirForArguments:arguments];
}

// unstaged
Expand Down Expand Up @@ -528,7 +532,10 @@ - (NSString *)diffForFile:(PBChangedFile *)file staged:(BOOL)staged contextLines
}
}

return [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-files", parameter, @"--", file.path, nil]];
NSMutableArray *arguments = [NSMutableArray arrayWithObjects:@"diff-files", parameter, @"--", file.path, nil];
if (![PBGitDefaults showWhitespaceDifferences])
[arguments insertObject:@"-w" atIndex:2];
return [repository outputInWorkdirForArguments:arguments];
}

- (void)postIndexChange
Expand Down
5 changes: 5 additions & 0 deletions html/views/commit/commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ var showFileChanges = function(file, cached) {
if (changes == "") {
notify("This file has no more changes", 1);
return;
}
else if (!changes){
notify("No changes in diff. Only whitespace changes?", 1);
diff.innerHTML = "";
return;
}

displayDiff(changes, cached);
Expand Down