mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
Better diff display
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#import "FileViewerController.h"
|
||||
#import "PBGitHistoryController.h"
|
||||
#import "PBGitDefaults.h"
|
||||
|
||||
#define GROUP_LABEL @"Label" // string
|
||||
#define GROUP_SEPARATOR @"HasSeparator" // BOOL as NSNumber
|
||||
@@ -33,6 +34,10 @@
|
||||
self.groups = [NSMutableArray arrayWithCapacity:0];
|
||||
scopeBar.delegate = self;
|
||||
NSArray *items = [NSArray arrayWithObjects:
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
(commit)?@"commit":@"diff", ITEM_IDENTIFIER,
|
||||
@"Diff", ITEM_NAME,
|
||||
nil],
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
@"source", ITEM_IDENTIFIER,
|
||||
@"Source", ITEM_NAME,
|
||||
@@ -41,10 +46,6 @@
|
||||
@"blame", ITEM_IDENTIFIER,
|
||||
@"Blame", ITEM_NAME,
|
||||
nil],
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
(commit)?@"commit":@"diff", ITEM_IDENTIFIER,
|
||||
@"Diff", ITEM_NAME,
|
||||
nil],
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
@"log", ITEM_IDENTIFIER,
|
||||
@"History", ITEM_NAME,
|
||||
@@ -78,6 +79,7 @@
|
||||
NSLog(@"[FileViewerController selectCommit:%@]",c);
|
||||
}
|
||||
|
||||
|
||||
#pragma mark MGScopeBarDelegate methods
|
||||
|
||||
|
||||
@@ -145,13 +147,16 @@
|
||||
|
||||
+ (BOOL)isSelectorExcludedFromWebScript:(SEL)sel
|
||||
{
|
||||
return YES;
|
||||
NSLog(@"[%@ %s]: self = %@ (%i)", [self class], _cmd, self,[self respondsToSelector:sel]);
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)windowObject forFrame:(WebFrame *)frame
|
||||
{
|
||||
id script = [sender windowScriptObject];
|
||||
NSLog(@"Controller: %@", controller);
|
||||
[script setValue:controller forKey:@"Controller"];
|
||||
[script setValue:[PBGitDefaults alloc] forKey:@"Config"];
|
||||
}
|
||||
|
||||
- (void)webView:(WebView *)webView addMessageToConsole:(NSDictionary *)dictionary
|
||||
@@ -175,8 +180,13 @@
|
||||
txt=[repository outputForArguments:[NSArray arrayWithObjects:@"show", [self refSpec], nil]];
|
||||
else if(show==@"blame")
|
||||
txt=[self parseBlame:[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"blame", @"-p", file, sha, nil]]];
|
||||
else if((show==@"diff") || (show==@"commit"))
|
||||
txt=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff", (sha!=nil)?sha:file , (sha!=nil)?file:nil, nil]];
|
||||
else if(show==@"diff"){
|
||||
NSString *diff_p=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"show", @"--pretty=format:", sha, file, nil]];
|
||||
NSString *diff_l=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff", file, nil]];
|
||||
txt=[NSString stringWithFormat:@"%@\n%@",diff_p,diff_l];
|
||||
}
|
||||
else if(show==@"commit")
|
||||
txt=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff", (sha!=nil)?sha:file, (sha!=nil)?file:nil, nil]];
|
||||
else if(show==@"log")
|
||||
txt=[self parseLog:[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"log", [NSString stringWithFormat:@"--pretty=format:%@",format], @"--", file, nil]]];
|
||||
else
|
||||
|
||||
@@ -202,4 +202,27 @@
|
||||
[[NSUserDefaults standardUserDefaults] setInteger:state forKey:kBranchFilterState];
|
||||
}
|
||||
|
||||
- (BOOL) isFeatureEnabled:(NSString *)feature
|
||||
{
|
||||
if([feature isEqualToString:@"gravatar"])
|
||||
return [PBGitDefaults isGravatarEnabled];
|
||||
else if([feature isEqualToString:@"gist"])
|
||||
return [PBGitDefaults isGistEnabled];
|
||||
else if([feature isEqualToString:@"confirmGist"])
|
||||
return [PBGitDefaults confirmPublicGists];
|
||||
else if([feature isEqualToString:@"publicGist"])
|
||||
return [PBGitDefaults isGistPublic];
|
||||
else if ([feature isEqualToString:@"showWhitespaceDifferences"])
|
||||
return [PBGitDefaults showWhitespaceDifferences];
|
||||
else
|
||||
return YES;
|
||||
}
|
||||
|
||||
+ (BOOL)isSelectorExcludedFromWebScript:(SEL)sel
|
||||
{
|
||||
NSLog(@"[%@ %s]: self = %@ (%i)", [self class], _cmd, self,[self respondsToSelector:sel]);
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -848,7 +848,7 @@ enum {
|
||||
|
||||
+ (BOOL)isSelectorExcludedFromWebScript:(SEL)sel
|
||||
{
|
||||
//NSLog(@"[%@ %s]: controller = %@ (%i)", [self class], _cmd, self,[self respondsToSelector:sel]);
|
||||
NSLog(@"[%@ %s]: self = %@ (%i)", [self class], _cmd, self,[self respondsToSelector:sel]);
|
||||
//return NO; //![controller respondsToSelector:sel];
|
||||
if (sel == @selector(selectCommit:)) return NO;
|
||||
return YES;
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
// using the console
|
||||
|
||||
var highlightDiff = function(diff, element, callbacks) {
|
||||
|
||||
alert("window="+window);
|
||||
alert("window.Config="+window.Config);
|
||||
alert("window.Config.isFeatureEnabled_="+window.Config.isFeatureEnabled_);
|
||||
|
||||
if (!diff || diff == "")
|
||||
return;
|
||||
|
||||
@@ -184,7 +189,7 @@ var highlightDiff = function(diff, element, callbacks) {
|
||||
|
||||
sindex = "index=" + lindex.toString() + " ";
|
||||
if (firstChar == "+") {
|
||||
if (window.Controller.isFeatureEnabled_("showWhitespaceDifferences")) {
|
||||
if (window.Config.isFeatureEnabled_("showWhitespaceDifferences")) {
|
||||
// Highlight trailing whitespace
|
||||
if (m = l.match(/\s+$/))
|
||||
l = l.replace(/\s+$/, "<span class='whitespace'>" + m + "</span>");
|
||||
|
||||
Reference in New Issue
Block a user