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:
Nathan Kinsinger
2010-02-27 10:06:25 -07:00
parent dc56af4aa6
commit c19d2c8058
10 changed files with 103 additions and 3 deletions
+30
View File
@@ -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