Skip to content

Commit 7da571b

Browse files
committed
Merge remote-tracking branch 'gitx/master'
2 parents 4bab0e3 + 73553aa commit 7da571b

16 files changed

+255
-154
lines changed

Classes/Controllers/PBGitHistoryController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
- (void)showCommitsFromTree:(id)sender;
7979

8080
// Find/Search methods
81+
- (void)setHistorySearch:(NSString *)searchString mode:(PBHistorySearchMode)mode;
8182
- (IBAction)selectNext:(id)sender;
8283
- (IBAction)selectPrevious:(id)sender;
8384

Classes/Controllers/PBGitHistoryController.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,11 @@ - (void)keyDown:(NSEvent*)event
371371
[super keyDown: event];
372372
}
373373

374+
- (void)setHistorySearch:(NSString *)searchString mode:(PBHistorySearchMode)mode
375+
{
376+
[searchController setHistorySearch:searchString mode:mode];
377+
}
378+
374379
// NSSearchField (actually textfields in general) prevent the normal Find operations from working. Setup custom actions for the
375380
// next and previous menuitems (in MainMenu.nib) so they will work when the search field is active. When searching for text in
376381
// a file make sure to call the Find panel's action method instead.
@@ -543,7 +548,7 @@ - (NSMenu *)tableColumnMenu
543548
- (void)showCommitsFromTree:(id)sender
544549
{
545550
NSString *searchString = [(NSArray *)[sender representedObject] componentsJoinedByString:@" "];
546-
[searchController setHistorySearch:searchString mode:PBHistorySearchModePath];
551+
[self setHistorySearch:searchString mode:PBHistorySearchModePath];
547552
}
548553

549554
- (void) checkoutFiles:(id)sender

Classes/Controllers/PBGitRepositoryDocument.m

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,24 @@ - (void)selectRevisionSpecifier:(PBGitRevSpecifier *)specifier {
111111
[self showHistoryView:self];
112112
}
113113

114-
- (void)showWindows {
114+
- (void)showWindows
115+
{
116+
NSScriptCommand *command = [NSScriptCommand currentCommand];
117+
118+
if (command) {
119+
// Check if `gitx` has provided some arguments
120+
NSURL *repoURL = [command directParameter];
121+
122+
// on app launch there may be many repositories opening, so double check that this is the right repo
123+
if (repoURL && [repoURL isKindOfClass:[NSURL class]]) {
124+
repoURL = [PBRepositoryFinder gitDirForURL:repoURL];
125+
if ([repoURL isEqual:_repository.gitURL]) {
126+
NSArray *arguments = command.arguments[@"openOptions"];
127+
[self handleGitXScriptingArguments:arguments];
128+
}
129+
}
130+
}
131+
115132
[[[self windowController] window] setTitle:[self displayName]];
116133
[super showWindows];
117134
}

Classes/Controllers/PBGitSidebarController.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
PBSourceViewItem *stage;
2828

2929
PBSourceViewItem *branches, *remotes, *tags, *others, *submodules, *stashes;
30-
31-
PBGitHistoryController *historyViewController;
32-
PBGitCommitController *commitViewController;
3330
}
3431

3532
- (void) selectStage;
@@ -40,13 +37,9 @@
4037

4138
- (IBAction) fetchPullPushAction:(id)sender;
4239

43-
- (void)setHistorySearch:(NSString *)searchString mode:(PBHistorySearchMode)mode;
44-
4540
@property(readonly) NSMutableArray *items;
4641
@property(readonly) PBSourceViewItem *remotes;
4742
@property(readonly) NSOutlineView *sourceView;
4843
@property(readonly) NSView *sourceListControlsView;
49-
@property(readonly) PBGitHistoryController *historyViewController;
50-
@property(readonly) PBGitCommitController *commitViewController;
5144

5245
@end

Classes/Controllers/PBGitSidebarController.m

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ @implementation PBGitSidebarController
3535
@synthesize remotes;
3636
@synthesize sourceView;
3737
@synthesize sourceListControlsView;
38-
@synthesize historyViewController;
39-
@synthesize commitViewController;
4038

4139
- (id)initWithRepository:(PBGitRepository *)theRepository superController:(PBGitWindowController *)controller
4240
{
@@ -53,9 +51,6 @@ - (void)awakeFromNib
5351
window.contentView = self.view;
5452
[self populateList];
5553

56-
historyViewController = [[PBGitHistoryController alloc] initWithRepository:repository superController:superController];
57-
commitViewController = [[PBGitCommitController alloc] initWithRepository:repository superController:superController];
58-
5954
[repository addObserver:self forKeyPath:@"currentBranch" options:0 context:@"currentBranchChange"];
6055
[repository addObserver:self forKeyPath:@"branches" options:(NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew) context:@"branchesModified"];
6156
[repository addObserver:self forKeyPath:@"stashes" options:0 context:@"stashesModified"];
@@ -83,9 +78,6 @@ - (void)dealloc
8378

8479
- (void)closeView
8580
{
86-
[historyViewController closeView];
87-
[commitViewController closeView];
88-
8981
[repository removeObserver:self forKeyPath:@"currentBranch"];
9082
[repository removeObserver:self forKeyPath:@"branches"];
9183
[repository removeObserver:self forKeyPath:@"stashes"];
@@ -215,11 +207,6 @@ - (void) removeRevSpec:(PBGitRevSpecifier *)rev
215207
[sourceView reloadData];
216208
}
217209

218-
- (void)setHistorySearch:(NSString *)searchString mode:(PBHistorySearchMode)mode
219-
{
220-
[historyViewController.searchController setHistorySearch:searchString mode:mode];
221-
}
222-
223210
- (void) openSubmoduleFromMenuItem:(NSMenuItem *)menuItem
224211
{
225212
[self openSubmoduleAtURL:[menuItem representedObject]];
@@ -244,12 +231,12 @@ - (void)outlineViewSelectionDidChange:(NSNotification *)notification
244231
if ([item revSpecifier]) {
245232
if (![repository.currentBranch isEqual:[item revSpecifier]])
246233
repository.currentBranch = [item revSpecifier];
247-
[superController changeContentController:historyViewController];
234+
[superController changeContentController:superController.historyViewController];
248235
[PBGitDefaults setShowStageView:NO];
249236
}
250237

251238
if (item == stage) {
252-
[superController changeContentController:commitViewController];
239+
[superController changeContentController:superController.commitViewController];
253240
[PBGitDefaults setShowStageView:YES];
254241
}
255242

@@ -258,12 +245,22 @@ - (void)outlineViewSelectionDidChange:(NSNotification *)notification
258245
}
259246

260247
- (void)doubleClicked:(id)object {
261-
NSInteger rowNumber = [sourceView selectedRow];
262-
if ([[sourceView itemAtRow:rowNumber] isKindOfClass:[PBGitSVSubmoduleItem class]]) {
263-
PBGitSVSubmoduleItem *subModule = [sourceView itemAtRow:rowNumber];
264-
265-
[self openSubmoduleAtURL:[subModule path]];
266-
}
248+
NSInteger rowNumber = [sourceView selectedRow];
249+
250+
id item = [sourceView itemAtRow:rowNumber];
251+
if ([item isKindOfClass:[PBGitSVSubmoduleItem class]]) {
252+
PBGitSVSubmoduleItem *subModule = item;
253+
254+
[self openSubmoduleAtURL:[subModule path]];
255+
} else if ([item isKindOfClass:[PBGitSVBranchItem class]]) {
256+
PBGitSVBranchItem *branch = item;
257+
258+
NSError *error = nil;
259+
BOOL success = [repository checkoutRefish:[branch ref] error:&error];
260+
if (!success) {
261+
[self.windowController showErrorSheet:error];
262+
}
263+
}
267264
}
268265

269266
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item
@@ -392,7 +389,7 @@ - (void) addMenuItemsForRef:(PBGitRef *)ref toMenu:(NSMenu *)menu
392389
if (!ref)
393390
return;
394391

395-
for (NSMenuItem *menuItem in [historyViewController.refController menuItemsForRef:ref])
392+
for (NSMenuItem *menuItem in [superController.historyViewController.refController menuItemsForRef:ref])
396393
[menu addItem:menuItem];
397394
}
398395

Classes/Controllers/PBGitWindowController.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
#import <Cocoa/Cocoa.h>
1010
#import "PBHistorySearchMode.h"
1111

12-
#undef GITX_DEPRECATED
13-
#define GITX_DEPRECATED
14-
15-
@class PBViewController, PBGitSidebarController, PBGitCommitController, PBGitRepository;
12+
@class PBViewController;
13+
@class PBGitSidebarController;
14+
@class PBGitCommitController;
15+
@class PBGitHistoryController;
16+
@class PBGitRepository;
1617
@class RJModalRepoSheet;
1718
@class PBGitRef;
1819
@class PBGitRepositoryDocument;
@@ -21,6 +22,9 @@
2122
__weak PBViewController *contentController;
2223

2324
PBGitSidebarController *sidebarController;
25+
PBGitHistoryController *_historyViewController;
26+
PBGitCommitController *_commitViewController;
27+
2428
__weak IBOutlet NSView *sourceListControlsView;
2529
__weak IBOutlet NSSplitView *splitView;
2630
__weak IBOutlet NSView *sourceSplitView;
@@ -33,6 +37,8 @@
3337
@property (nonatomic, strong) PBGitRepository *repository;
3438
/* This is assign because that's what NSWindowController says :-S */
3539
@property (assign) PBGitRepositoryDocument *document;
40+
@property (readonly) PBGitHistoryController *historyViewController;
41+
@property (readonly) PBGitCommitController *commitViewController;
3642

3743
- (instancetype)init;
3844

0 commit comments

Comments
 (0)