25
25
#define QLPreviewPanel NSClassFromString (@" QLPreviewPanel" )
26
26
#import " PBQLTextView.h"
27
27
#import " GLFileView.h"
28
+ #import " PBGitWindowController.h"
28
29
29
30
30
31
#define kHistorySelectedDetailIndexKey @" PBHistorySelectedDetailIndex"
@@ -53,10 +54,10 @@ - (void)awakeFromNib
53
54
[self .commitController addObserver: self forKeyPath: @" arrangedObjects.@count" options: NSKeyValueObservingOptionInitial context: @" updateCommitCount" ];
54
55
[self .treeController addObserver: self forKeyPath: @" selection" options: 0 context: @" treeChange" ];
55
56
56
- [repository.revisionList addObserver: self forKeyPath: @" isUpdating" options: 0 context: @" revisionListUpdating" ];
57
- [repository addObserver: self forKeyPath: @" currentBranch" options: 0 context: @" branchChange" ];
58
- [repository addObserver: self forKeyPath: @" refs" options: 0 context: @" updateRefs" ];
59
- [repository addObserver: self forKeyPath: @" currentBranchFilter" options: 0 context: @" branchFilterChange" ];
57
+ [self . repository.revisionList addObserver: self forKeyPath: @" isUpdating" options: 0 context: @" revisionListUpdating" ];
58
+ [self . repository addObserver: self forKeyPath: @" currentBranch" options: 0 context: @" branchChange" ];
59
+ [self . repository addObserver: self forKeyPath: @" refs" options: 0 context: @" updateRefs" ];
60
+ [self . repository addObserver: self forKeyPath: @" currentBranchFilter" options: 0 context: @" branchFilterChange" ];
60
61
61
62
forceSelectionUpdate = YES ;
62
63
NSSize cellSpacing = [self .commitList intercellSpacing ];
@@ -65,14 +66,14 @@ - (void)awakeFromNib
65
66
[fileBrowser setTarget: self ];
66
67
[fileBrowser setDoubleAction: @selector (openSelectedFile: )];
67
68
68
- if (!repository.currentBranch ) {
69
- [repository reloadRefs ];
70
- [repository readCurrentBranch ];
69
+ if (!self.repository .currentBranch ) {
70
+ [self .repository reloadRefs ];
71
+ [self .repository readCurrentBranch ];
72
+ } else {
73
+ [self .repository lazyReload ];
71
74
}
72
- else
73
- [repository lazyReload ];
74
75
75
- if (![repository hasSVNRemote ])
76
+ if (![self . repository hasSVNRemote ])
76
77
{
77
78
// Remove the SVN revision table column for repositories with no SVN remote configured
78
79
[self .commitList removeTableColumn: [self .commitList tableColumnWithIdentifier: @" GitSVNRevision" ]];
@@ -94,7 +95,7 @@ - (void)awakeFromNib
94
95
[self updateBranchFilterMatrix ];
95
96
96
97
// listen for updates
97
- [[NSNotificationCenter defaultCenter ] addObserver: self selector: @selector (_repositoryUpdatedNotification: ) name: PBGitRepositoryEventNotification object: repository];
98
+ [[NSNotificationCenter defaultCenter ] addObserver: self selector: @selector (_repositoryUpdatedNotification: ) name: PBGitRepositoryEventNotification object: self . repository];
98
99
99
100
[super awakeFromNib ];
100
101
}
@@ -139,11 +140,11 @@ - (void)updateKeys
139
140
140
141
- (void ) updateBranchFilterMatrix
141
142
{
142
- if ([repository.currentBranch isSimpleRef ]) {
143
+ if ([self . repository.currentBranch isSimpleRef ]) {
143
144
[allBranchesFilterItem setEnabled: YES ];
144
145
[localRemoteBranchesFilterItem setEnabled: YES ];
145
146
146
- NSInteger filter = repository.currentBranchFilter ;
147
+ NSInteger filter = self. repository .currentBranchFilter ;
147
148
[allBranchesFilterItem setState: (filter == kGitXAllBranchesFilter )];
148
149
[localRemoteBranchesFilterItem setState: (filter == kGitXLocalRemoteBranchesFilter )];
149
150
[selectedBranchFilterItem setState: (filter == kGitXSelectedBranchFilter )];
@@ -158,10 +159,10 @@ - (void) updateBranchFilterMatrix
158
159
[selectedBranchFilterItem setState: YES ];
159
160
}
160
161
161
- [selectedBranchFilterItem setTitle: [repository.currentBranch title ]];
162
+ [selectedBranchFilterItem setTitle: [self . repository.currentBranch title ]];
162
163
[selectedBranchFilterItem sizeToFit ];
163
164
164
- [localRemoteBranchesFilterItem setTitle: [[repository.currentBranch ref ] isRemote ] ? @" Remote" : @" Local" ];
165
+ [localRemoteBranchesFilterItem setTitle: [[self . repository.currentBranch ref ] isRemote ] ? @" Remote" : @" Local" ];
165
166
}
166
167
167
168
- (PBGitCommit *) firstCommit
@@ -196,7 +197,7 @@ - (int) selectedCommitDetailsIndex
196
197
197
198
- (void ) updateStatus
198
199
{
199
- self.isBusy = repository.revisionList .isUpdating ;
200
+ self.isBusy = self. repository .revisionList .isUpdating ;
200
201
self.status = [NSString stringWithFormat: @" %lu commits loaded" , [[self .commitController arrangedObjects ] count ]];
201
202
}
202
203
@@ -272,16 +273,16 @@ - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(
272
273
}
273
274
274
275
if ([strContext isEqualToString: @" branchFilterChange" ]) {
275
- [PBGitDefaults setBranchFilter: repository.currentBranchFilter];
276
+ [PBGitDefaults setBranchFilter: self . repository.currentBranchFilter];
276
277
[self updateBranchFilterMatrix ];
277
278
return ;
278
279
}
279
280
280
281
if ([strContext isEqualToString: @" updateCommitCount" ] || [(__bridge NSString *)context isEqualToString: @" revisionListUpdating" ]) {
281
282
[self updateStatus ];
282
283
283
- if ([repository.currentBranch isSimpleRef ])
284
- [self selectCommit: [repository shaForRef: [repository.currentBranch ref ]]];
284
+ if ([self . repository.currentBranch isSimpleRef ])
285
+ [self selectCommit: [self . repository shaForRef: [self . repository.currentBranch ref ]]];
285
286
else
286
287
[self selectCommit: [[self firstCommit ] sha ]];
287
288
return ;
@@ -324,16 +325,16 @@ - (IBAction) setTreeView:(id)sender
324
325
325
326
- (IBAction ) setBranchFilter : (id )sender
326
327
{
327
- repository.currentBranchFilter = [(NSView *)sender tag ];
328
- [PBGitDefaults setBranchFilter: repository.currentBranchFilter];
328
+ self. repository .currentBranchFilter = [(NSView *)sender tag ];
329
+ [PBGitDefaults setBranchFilter: self . repository.currentBranchFilter];
329
330
[self updateBranchFilterMatrix ];
330
331
forceSelectionUpdate = YES ;
331
332
}
332
333
333
334
- (void )keyDown : (NSEvent *)event
334
335
{
335
336
if ([[event charactersIgnoringModifiers ] isEqualToString: @" f" ] && [event modifierFlags ] & NSAlternateKeyMask && [event modifierFlags ] & NSCommandKeyMask )
336
- [superController.window makeFirstResponder: searchField];
337
+ [self . superController.window makeFirstResponder: searchField];
337
338
else
338
339
[super keyDown: event];
339
340
}
@@ -435,7 +436,7 @@ - (void) updateQuicklookForce:(BOOL)force
435
436
436
437
- (IBAction ) refresh : (id )sender
437
438
{
438
- [repository forceUpdateRevisions ];
439
+ [self . repository forceUpdateRevisions ];
439
440
}
440
441
441
442
- (void ) updateView
@@ -513,10 +514,10 @@ - (void)closeView
513
514
[self .commitController removeObserver: self forKeyPath: @" arrangedObjects.@count" ];
514
515
[self .treeController removeObserver: self forKeyPath: @" selection" ];
515
516
516
- [repository.revisionList removeObserver: self forKeyPath: @" isUpdating" ];
517
- [repository removeObserver: self forKeyPath: @" currentBranch" ];
518
- [repository removeObserver: self forKeyPath: @" refs" ];
519
- [repository removeObserver: self forKeyPath: @" currentBranchFilter" ];
517
+ [self . repository.revisionList removeObserver: self forKeyPath: @" isUpdating" ];
518
+ [self . repository removeObserver: self forKeyPath: @" currentBranch" ];
519
+ [self . repository removeObserver: self forKeyPath: @" refs" ];
520
+ [self . repository removeObserver: self forKeyPath: @" currentBranchFilter" ];
520
521
}
521
522
522
523
[webHistoryController closeView ];
@@ -551,7 +552,7 @@ - (void)showCommitsFromTree:(id)sender
551
552
552
553
- (void )showInFinderAction : (id )sender
553
554
{
554
- NSString *workingDirectory = [[repository workingDirectory ] stringByAppendingString: @" /" ];
555
+ NSString *workingDirectory = [[self . repository workingDirectory ] stringByAppendingString: @" /" ];
555
556
NSString *path;
556
557
NSWorkspace *ws = [NSWorkspace sharedWorkspace ];
557
558
@@ -564,7 +565,7 @@ - (void)showInFinderAction:(id)sender
564
565
565
566
- (void )openFilesAction : (id )sender
566
567
{
567
- NSString *workingDirectory = [[repository workingDirectory ] stringByAppendingString: @" /" ];
568
+ NSString *workingDirectory = [[self . repository workingDirectory ] stringByAppendingString: @" /" ];
568
569
NSString *path;
569
570
NSWorkspace *ws = [NSWorkspace sharedWorkspace ];
570
571
@@ -580,7 +581,7 @@ - (void) checkoutFiles:(id)sender
580
581
for (NSString *filePath in [sender representedObject ])
581
582
[files addObject: [filePath stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceCharacterSet ]]];
582
583
583
- [repository checkoutFiles: files fromRefish: selectedCommit];
584
+ [self . repository checkoutFiles: files fromRefish: selectedCommit];
584
585
}
585
586
586
587
- (void ) diffFilesAction : (id )sender
@@ -609,10 +610,10 @@ - (NSArray *)menuItemsForPaths:(NSArray *)paths
609
610
action: @selector (showCommitsFromTree: )
610
611
keyEquivalent: @" " ];
611
612
612
- PBGitRef *headRef = [[repository headRef ] ref ];
613
+ PBGitRef *headRef = [[self . repository headRef ] ref ];
613
614
NSString *headRefName = [headRef shortName ];
614
615
NSString *diffTitle = [NSString stringWithFormat: @" Diff %@ with %@ " , multiple ? @" files" : @" file" , headRefName];
615
- BOOL isHead = [[selectedCommit sha ] isEqual: [repository headSHA ]];
616
+ BOOL isHead = [[selectedCommit sha ] isEqual: [self . repository headSHA ]];
616
617
NSMenuItem *diffItem = [[NSMenuItem alloc ] initWithTitle: diffTitle
617
618
action: isHead ? nil : @selector (diffFilesAction: )
618
619
keyEquivalent: @" " ];
@@ -715,20 +716,22 @@ - (void)restoreSplitViewPositiion
715
716
716
717
- (IBAction ) createBranch : (id )sender
717
718
{
718
- PBGitRef *currentRef = [repository.currentBranch ref ];
719
+ PBGitRef *currentRef = [self . repository.currentBranch ref ];
719
720
720
- if (!selectedCommit || [selectedCommit hasRef: currentRef])
721
+ if (!selectedCommit || [selectedCommit hasRef: currentRef]) {
721
722
[PBCreateBranchSheet beginCreateBranchSheetAtRefish: currentRef inRepository: self .repository];
722
- else
723
+ } else {
723
724
[PBCreateBranchSheet beginCreateBranchSheetAtRefish: selectedCommit inRepository: self .repository];
725
+ }
724
726
}
725
727
726
728
- (IBAction ) createTag : (id )sender
727
729
{
728
- if (!selectedCommit)
729
- [PBCreateTagSheet beginCreateTagSheetAtRefish: [repository.currentBranch ref ] inRepository: repository];
730
- else
731
- [PBCreateTagSheet beginCreateTagSheetAtRefish: selectedCommit inRepository: repository];
730
+ if (!selectedCommit) {
731
+ [PBCreateTagSheet beginCreateTagSheetAtRefish: [self .repository.currentBranch ref ] inRepository: self .repository];
732
+ } else {
733
+ [PBCreateTagSheet beginCreateTagSheetAtRefish: selectedCommit inRepository: self .repository];
734
+ }
732
735
}
733
736
734
737
- (IBAction ) showAddRemoteSheet : (id )sender
@@ -738,20 +741,23 @@ - (IBAction) showAddRemoteSheet:(id)sender
738
741
739
742
- (IBAction ) merge : (id )sender
740
743
{
741
- if (selectedCommit)
742
- [repository mergeWithRefish: selectedCommit];
744
+ if (selectedCommit) {
745
+ [self .repository mergeWithRefish: selectedCommit];
746
+ }
743
747
}
744
748
745
749
- (IBAction ) cherryPick : (id )sender
746
750
{
747
- if (selectedCommit)
748
- [repository cherryPickRefish: selectedCommit];
751
+ if (selectedCommit) {
752
+ [self .repository cherryPickRefish: selectedCommit];
753
+ }
749
754
}
750
755
751
756
- (IBAction ) rebase : (id )sender
752
757
{
753
- if (selectedCommit)
754
- [repository rebaseBranch: nil onRefish: selectedCommit];
758
+ if (selectedCommit) {
759
+ [self .repository rebaseBranch: nil onRefish: selectedCommit];
760
+ }
755
761
}
756
762
757
763
#pragma mark -
0 commit comments