Permalink
Browse files

Add support for going directly to blame for a file from the command line

When launching from command line, switch to detail view (unless --blame is present)
When passing files after -- from command line, select first file in file browser
  • Loading branch information...
1 parent 098125d commit 70aca227f1afe260d18e6f04550061f4c1c8c3be @sleifer committed Aug 28, 2010
Showing with 33 additions and 4 deletions.
  1. +26 −1 PBCLIProxy.m
  2. +3 −0 PBGitHistoryController.h
  3. +1 −1 PBGitHistoryController.m
  4. +1 −0 PBGitWindowController.h
  5. +1 −1 PBGitWindowController.m
  6. +1 −1 gitx.m
View
@@ -11,8 +11,10 @@
#import "PBGitRevSpecifier.h"
#import "PBGitRepository.h"
#import "PBGitWindowController.h"
+#import "PBGitSidebarController.h"
#import "PBGitBinary.h"
#import "PBDiffWindowController.h"
+#import "PBGitHistoryController.h"
@implementation PBCLIProxy
@synthesize connection;
@@ -36,7 +38,7 @@ - (BOOL)openRepository:(NSURL*)repositoryPath arguments: (NSArray*) args error:(
// work around an apparent bug with GC and Distributed Objects
// I am not familiar with GC though, so perhaps I was doing something wrong.
NSURL* url = [NSURL fileURLWithPath:[repositoryPath path]];
- NSArray* arguments = [NSArray arrayWithArray:args];
+ NSMutableArray* arguments = [NSMutableArray arrayWithArray:args];
PBGitRepository *document = nil;
@try {
@@ -59,10 +61,33 @@ - (BOOL)openRepository:(NSURL*)repositoryPath arguments: (NSArray*) args error:(
[[arguments objectAtIndex:0] isEqualToString:@"-c"]))
[document.windowController showCommitView:self];
else {
+ BOOL blame = NO;
+ if ([arguments containsObject:@"--blame"]) {
+ blame = YES;
+ [arguments removeObject:@"--blame"];
+ }
+
PBGitRevSpecifier* rev = [[PBGitRevSpecifier alloc] initWithParameters:arguments];
rev.workingDirectory = url;
document.currentBranch = [document addBranch: rev];
[document.windowController showHistoryView:self];
+
+ PBGitHistoryController *historyController = document.windowController.sidebarController.historyViewController;
+
+ if ([rev.parameters count] > 1 && [rev.parameters containsObject:@"--"]) {
+ NSUInteger index = [rev.parameters indexOfObject:@"--"];
+ if ([rev.parameters count] > (index + 1)) {
+ NSString *firstPath = [rev.parameters objectAtIndex:index + 1];
+ historyController.currentFileBrowserSelectionPath = [NSArray arrayWithObject:firstPath];
+ [historyController restoreFileBrowserSelection];
+ }
+ }
+ if (blame) {
+ [historyController setBlameView:self];
+ } else {
+ [historyController setDetailedView:self];
+ }
+
}
[NSApp activateIgnoringOtherApps:YES];
View
@@ -63,6 +63,7 @@
@property (readonly) NSArrayController *commitController;
@property (readonly) PBRefController *refController;
@property (retain) NSArray *lastSearchSelection;
+@property (retain) NSArray *currentFileBrowserSelectionPath;
- (IBAction) setDetailedView:(id)sender;
- (IBAction) setTreeView:(id)sender;
@@ -104,4 +105,6 @@
- (CGFloat)splitView:(NSSplitView *)sender constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)offset;
- (CGFloat)splitView:(NSSplitView *)sender constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)offset;
+- (void) restoreFileBrowserSelection;
+
@end
View
@@ -40,7 +40,7 @@ - (void) saveFileBrowserSelection;
@implementation PBGitHistoryController
-@synthesize selectedCommitDetailsIndex, webCommit, gitTree, commitController, refController, lastSearchSelection;
+@synthesize selectedCommitDetailsIndex, webCommit, gitTree, commitController, refController, lastSearchSelection, currentFileBrowserSelectionPath;
- (void)awakeFromNib
{
View
@@ -32,6 +32,7 @@
}
@property (assign) __weak PBGitRepository *repository;
+@property (readonly) PBGitSidebarController *sidebarController;
- (id)initWithRepository:(PBGitRepository*)theRepository displayDefault:(BOOL)display;
View
@@ -17,7 +17,7 @@
@implementation PBGitWindowController
-@synthesize repository;
+@synthesize repository, sidebarController;
- (id)initWithRepository:(PBGitRepository*)theRepository displayDefault:(BOOL)displayDefault
{
View
2 gitx.m
@@ -50,7 +50,7 @@ void usage(char const *programName)
printf("Usage: %s (--help|--version)\n", programName);
printf(" or: %s (--commit|-h)\n", programName);
- printf(" or: %s <revlist options>\n", programName);
+ printf(" or: %s [--blame] <revlist options>\n", programName);
printf("\n");
printf("\t-h, --help print this help\n");
printf("\t--commit, -c start GitX in commit mode\n");

0 comments on commit 70aca22

Please sign in to comment.