From 820fa6ad53d91e224ac7ea7d4ac1c45725b696d7 Mon Sep 17 00:00:00 2001 From: Andrew Ryan Date: Wed, 25 Apr 2012 15:14:45 -0400 Subject: [PATCH] Handle "Show whitespace differences" in commit view --- PBGitIndex.m | 11 +++++++++-- html/views/commit/commit.js | 5 +++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/PBGitIndex.m b/PBGitIndex.m index 3abef4ddf..51390d072 100644 --- a/PBGitIndex.m +++ b/PBGitIndex.m @@ -10,6 +10,7 @@ #import "PBGitRepository.h" #import "PBGitBinary.h" #import "PBEasyPipe.h" +#import "PBGitDefaults.h" #import "NSString_RegEx.h" #import "PBChangedFile.h" @@ -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 @@ -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 diff --git a/html/views/commit/commit.js b/html/views/commit/commit.js index 2c6cda6a0..49ba73f45 100644 --- a/html/views/commit/commit.js +++ b/html/views/commit/commit.js @@ -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);