mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
Add Diff to contextual menus
- added to menus for refs, commits, and files
- show a message when there are no changes
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
//
|
||||
|
||||
#import "PBDiffWindowController.h"
|
||||
#import "PBGitRepository.h"
|
||||
#import "PBGitCommit.h"
|
||||
|
||||
|
||||
@implementation PBDiffWindowController
|
||||
@@ -21,4 +23,32 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
+ (void) showDiffWindowWithFiles:(NSArray *)filePaths fromCommit:(PBGitCommit *)startCommit diffCommit:(PBGitCommit *)diffCommit
|
||||
{
|
||||
if (!startCommit)
|
||||
return;
|
||||
|
||||
if (!diffCommit)
|
||||
diffCommit = [startCommit.repository headCommit];
|
||||
|
||||
NSString *commitSelector = [NSString stringWithFormat:@"%@..%@", [startCommit realSha], [diffCommit realSha]];
|
||||
NSMutableArray *arguments = [NSMutableArray arrayWithObjects:@"diff", commitSelector, nil];
|
||||
if (filePaths) {
|
||||
[arguments addObject:@"--"];
|
||||
[arguments addObjectsFromArray:filePaths];
|
||||
}
|
||||
|
||||
int retValue;
|
||||
NSString *diff = [startCommit.repository outputInWorkdirForArguments:arguments retValue:&retValue];
|
||||
if (retValue) {
|
||||
NSLog(@"diff failed with retValue: %d for command: '%@' output: '%@'", retValue, [arguments componentsJoinedByString:@" "], diff);
|
||||
return;
|
||||
}
|
||||
|
||||
PBDiffWindowController *diffController = [[PBDiffWindowController alloc] initWithDiff:[diff copy]];
|
||||
[diffController showWindow:nil];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user