Skip to content

Commit 1477c46

Browse files
committed
Issue #13 - cleaning up ivar storage
Remove @synthesize & use self.
1 parent 9571382 commit 1477c46

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+399
-450
lines changed

Classes/Controllers/PBGitCommitController.m

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#import "PBGitIndex.h"
1414
#import "PBNiceSplitView.h"
1515
#import "PBGitRepositoryWatcher.h"
16+
#import "PBGitWindowController.h"
1617

1718
#import <ObjectiveGit/GTRepository.h>
1819
#import <ObjectiveGit/GTConfiguration.h>
@@ -75,7 +76,7 @@ - (void)awakeFromNib
7576
[[NSSortDescriptor alloc] initWithKey:@"path" ascending:true]]];
7677

7778
// listen for updates
78-
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_repositoryUpdatedNotification:) name:PBGitRepositoryEventNotification object:repository];
79+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_repositoryUpdatedNotification:) name:PBGitRepositoryEventNotification object:self.repository];
7980

8081
[cachedFilesController setAutomaticallyRearrangesObjects:NO];
8182
[unstagedFilesController setAutomaticallyRearrangesObjects:NO];
@@ -106,10 +107,10 @@ - (NSResponder *)firstResponder;
106107

107108
- (IBAction)signOff:(id)sender
108109
{
109-
NSString* userName = [repository.gtRepo.configuration stringForKey:@"user.name"];
110-
NSString* userEmail = [repository.gtRepo.configuration stringForKey:@"user.email"];
110+
NSString* userName = [self.repository.gtRepo.configuration stringForKey:@"user.name"];
111+
NSString* userEmail = [self.repository.gtRepo.configuration stringForKey:@"user.email"];
111112
if (!(userName && userEmail))
112-
return [[repository windowController] showMessageSheet:@"User's name not set" infoText:@"Signing off a commit requires setting user.name and user.email in your git config"];
113+
return [[self.repository windowController] showMessageSheet:@"User's name not set" infoText:@"Signing off a commit requires setting user.name and user.email in your git config"];
113114
NSString *SOBline = [NSString stringWithFormat:@"Signed-off-by: %@ <%@>",
114115
userName,
115116
userEmail];
@@ -129,7 +130,7 @@ - (void) refresh:(id) sender
129130
[self.index refresh];
130131

131132
// Reload refs (in case HEAD changed)
132-
[repository reloadRefs];
133+
[self.repository reloadRefs];
133134
}
134135

135136
- (void) updateView
@@ -149,19 +150,19 @@ - (IBAction) forceCommit:(id) sender
149150

150151
- (void) commitWithVerification:(BOOL) doVerify
151152
{
152-
if ([[NSFileManager defaultManager] fileExistsAtPath:[repository.gitURL.path stringByAppendingPathComponent:@"MERGE_HEAD"]]) {
153-
[[repository windowController] showMessageSheet:@"Cannot commit merges" infoText:@"GitX cannot commit merges yet. Please commit your changes from the command line."];
153+
if ([[NSFileManager defaultManager] fileExistsAtPath:[self.repository.gitURL.path stringByAppendingPathComponent:@"MERGE_HEAD"]]) {
154+
[[self.repository windowController] showMessageSheet:@"Cannot commit merges" infoText:@"GitX cannot commit merges yet. Please commit your changes from the command line."];
154155
return;
155156
}
156157

157158
if ([[cachedFilesController arrangedObjects] count] == 0) {
158-
[[repository windowController] showMessageSheet:@"No changes to commit" infoText:@"You must first stage some changes before committing"];
159+
[[self.repository windowController] showMessageSheet:@"No changes to commit" infoText:@"You must first stage some changes before committing"];
159160
return;
160161
}
161162

162163
NSString *commitMessage = [commitMessageView string];
163164
if ([commitMessage length] < 3) {
164-
[[repository windowController] showMessageSheet:@"Commitmessage missing" infoText:@"Please enter a commit message before committing"];
165+
[[self.repository windowController] showMessageSheet:@"Commitmessage missing" infoText:@"Please enter a commit message before committing"];
165166
return;
166167
}
167168

@@ -200,7 +201,7 @@ - (void)commitFailed:(NSNotification *)notification
200201
NSString *reason = [[notification userInfo] objectForKey:@"description"];
201202
self.status = [@"Commit failed: " stringByAppendingString:reason];
202203
[commitMessageView setEditable:YES];
203-
[[repository windowController] showMessageSheet:@"Commit failed" infoText:reason];
204+
[[self.repository windowController] showMessageSheet:@"Commit failed" infoText:reason];
204205
}
205206

206207
- (void)commitHookFailed:(NSNotification *)notification
@@ -209,7 +210,7 @@ - (void)commitHookFailed:(NSNotification *)notification
209210
NSString *reason = [[notification userInfo] objectForKey:@"description"];
210211
self.status = [@"Commit hook failed: " stringByAppendingString:reason];
211212
[commitMessageView setEditable:YES];
212-
[[repository windowController] showCommitHookFailedSheet:@"Commit hook failed" infoText:reason commitController:self];
213+
[[self.repository windowController] showCommitHookFailedSheet:@"Commit hook failed" infoText:reason commitController:self];
213214
}
214215

215216
- (void)amendCommit:(NSNotification *)notification
@@ -237,7 +238,7 @@ - (void)indexChanged:(NSNotification *)notification
237238

238239
- (void)indexOperationFailed:(NSNotification *)notification
239240
{
240-
[[repository windowController] showMessageSheet:@"Index operation failed" infoText:[[notification userInfo] objectForKey:@"description"]];
241+
[[self.repository windowController] showMessageSheet:@"Index operation failed" infoText:[[notification userInfo] objectForKey:@"description"]];
241242
}
242243

243244

Classes/Controllers/PBGitHistoryController.m

Lines changed: 51 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#define QLPreviewPanel NSClassFromString(@"QLPreviewPanel")
2626
#import "PBQLTextView.h"
2727
#import "GLFileView.h"
28+
#import "PBGitWindowController.h"
2829

2930

3031
#define kHistorySelectedDetailIndexKey @"PBHistorySelectedDetailIndex"
@@ -53,10 +54,10 @@ - (void)awakeFromNib
5354
[self.commitController addObserver:self forKeyPath:@"arrangedObjects.@count" options:NSKeyValueObservingOptionInitial context:@"updateCommitCount"];
5455
[self.treeController addObserver:self forKeyPath:@"selection" options:0 context:@"treeChange"];
5556

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"];
6061

6162
forceSelectionUpdate = YES;
6263
NSSize cellSpacing = [self.commitList intercellSpacing];
@@ -65,14 +66,14 @@ - (void)awakeFromNib
6566
[fileBrowser setTarget:self];
6667
[fileBrowser setDoubleAction:@selector(openSelectedFile:)];
6768

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];
7174
}
72-
else
73-
[repository lazyReload];
7475

75-
if (![repository hasSVNRemote])
76+
if (![self.repository hasSVNRemote])
7677
{
7778
// Remove the SVN revision table column for repositories with no SVN remote configured
7879
[self.commitList removeTableColumn:[self.commitList tableColumnWithIdentifier:@"GitSVNRevision"]];
@@ -94,7 +95,7 @@ - (void)awakeFromNib
9495
[self updateBranchFilterMatrix];
9596

9697
// 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];
9899

99100
[super awakeFromNib];
100101
}
@@ -139,11 +140,11 @@ - (void)updateKeys
139140

140141
- (void) updateBranchFilterMatrix
141142
{
142-
if ([repository.currentBranch isSimpleRef]) {
143+
if ([self.repository.currentBranch isSimpleRef]) {
143144
[allBranchesFilterItem setEnabled:YES];
144145
[localRemoteBranchesFilterItem setEnabled:YES];
145146

146-
NSInteger filter = repository.currentBranchFilter;
147+
NSInteger filter = self.repository.currentBranchFilter;
147148
[allBranchesFilterItem setState:(filter == kGitXAllBranchesFilter)];
148149
[localRemoteBranchesFilterItem setState:(filter == kGitXLocalRemoteBranchesFilter)];
149150
[selectedBranchFilterItem setState:(filter == kGitXSelectedBranchFilter)];
@@ -158,10 +159,10 @@ - (void) updateBranchFilterMatrix
158159
[selectedBranchFilterItem setState:YES];
159160
}
160161

161-
[selectedBranchFilterItem setTitle:[repository.currentBranch title]];
162+
[selectedBranchFilterItem setTitle:[self.repository.currentBranch title]];
162163
[selectedBranchFilterItem sizeToFit];
163164

164-
[localRemoteBranchesFilterItem setTitle:[[repository.currentBranch ref] isRemote] ? @"Remote" : @"Local"];
165+
[localRemoteBranchesFilterItem setTitle:[[self.repository.currentBranch ref] isRemote] ? @"Remote" : @"Local"];
165166
}
166167

167168
- (PBGitCommit *) firstCommit
@@ -196,7 +197,7 @@ - (int) selectedCommitDetailsIndex
196197

197198
- (void) updateStatus
198199
{
199-
self.isBusy = repository.revisionList.isUpdating;
200+
self.isBusy = self.repository.revisionList.isUpdating;
200201
self.status = [NSString stringWithFormat:@"%lu commits loaded", [[self.commitController arrangedObjects] count]];
201202
}
202203

@@ -272,16 +273,16 @@ - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(
272273
}
273274

274275
if ([strContext isEqualToString:@"branchFilterChange"]) {
275-
[PBGitDefaults setBranchFilter:repository.currentBranchFilter];
276+
[PBGitDefaults setBranchFilter:self.repository.currentBranchFilter];
276277
[self updateBranchFilterMatrix];
277278
return;
278279
}
279280

280281
if([strContext isEqualToString:@"updateCommitCount"] || [(__bridge NSString *)context isEqualToString:@"revisionListUpdating"]) {
281282
[self updateStatus];
282283

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]]];
285286
else
286287
[self selectCommit:[[self firstCommit] sha]];
287288
return;
@@ -324,16 +325,16 @@ - (IBAction) setTreeView:(id)sender
324325

325326
- (IBAction) setBranchFilter:(id)sender
326327
{
327-
repository.currentBranchFilter = [(NSView*)sender tag];
328-
[PBGitDefaults setBranchFilter:repository.currentBranchFilter];
328+
self.repository.currentBranchFilter = [(NSView*)sender tag];
329+
[PBGitDefaults setBranchFilter:self.repository.currentBranchFilter];
329330
[self updateBranchFilterMatrix];
330331
forceSelectionUpdate = YES;
331332
}
332333

333334
- (void)keyDown:(NSEvent*)event
334335
{
335336
if ([[event charactersIgnoringModifiers] isEqualToString: @"f"] && [event modifierFlags] & NSAlternateKeyMask && [event modifierFlags] & NSCommandKeyMask)
336-
[superController.window makeFirstResponder: searchField];
337+
[self.superController.window makeFirstResponder: searchField];
337338
else
338339
[super keyDown: event];
339340
}
@@ -435,7 +436,7 @@ - (void) updateQuicklookForce:(BOOL)force
435436

436437
- (IBAction) refresh:(id)sender
437438
{
438-
[repository forceUpdateRevisions];
439+
[self.repository forceUpdateRevisions];
439440
}
440441

441442
- (void) updateView
@@ -513,10 +514,10 @@ - (void)closeView
513514
[self.commitController removeObserver:self forKeyPath:@"arrangedObjects.@count"];
514515
[self.treeController removeObserver:self forKeyPath:@"selection"];
515516

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"];
520521
}
521522

522523
[webHistoryController closeView];
@@ -551,7 +552,7 @@ - (void)showCommitsFromTree:(id)sender
551552

552553
- (void)showInFinderAction:(id)sender
553554
{
554-
NSString *workingDirectory = [[repository workingDirectory] stringByAppendingString:@"/"];
555+
NSString *workingDirectory = [[self.repository workingDirectory] stringByAppendingString:@"/"];
555556
NSString *path;
556557
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
557558

@@ -564,7 +565,7 @@ - (void)showInFinderAction:(id)sender
564565

565566
- (void)openFilesAction:(id)sender
566567
{
567-
NSString *workingDirectory = [[repository workingDirectory] stringByAppendingString:@"/"];
568+
NSString *workingDirectory = [[self.repository workingDirectory] stringByAppendingString:@"/"];
568569
NSString *path;
569570
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
570571

@@ -580,7 +581,7 @@ - (void) checkoutFiles:(id)sender
580581
for (NSString *filePath in [sender representedObject])
581582
[files addObject:[filePath stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]];
582583

583-
[repository checkoutFiles:files fromRefish:selectedCommit];
584+
[self.repository checkoutFiles:files fromRefish:selectedCommit];
584585
}
585586

586587
- (void) diffFilesAction:(id)sender
@@ -609,10 +610,10 @@ - (NSArray *)menuItemsForPaths:(NSArray *)paths
609610
action:@selector(showCommitsFromTree:)
610611
keyEquivalent:@""];
611612

612-
PBGitRef *headRef = [[repository headRef] ref];
613+
PBGitRef *headRef = [[self.repository headRef] ref];
613614
NSString *headRefName = [headRef shortName];
614615
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]];
616617
NSMenuItem *diffItem = [[NSMenuItem alloc] initWithTitle:diffTitle
617618
action:isHead ? nil : @selector(diffFilesAction:)
618619
keyEquivalent:@""];
@@ -715,20 +716,22 @@ - (void)restoreSplitViewPositiion
715716

716717
- (IBAction) createBranch:(id)sender
717718
{
718-
PBGitRef *currentRef = [repository.currentBranch ref];
719+
PBGitRef *currentRef = [self.repository.currentBranch ref];
719720

720-
if (!selectedCommit || [selectedCommit hasRef:currentRef])
721+
if (!selectedCommit || [selectedCommit hasRef:currentRef]) {
721722
[PBCreateBranchSheet beginCreateBranchSheetAtRefish:currentRef inRepository:self.repository];
722-
else
723+
} else {
723724
[PBCreateBranchSheet beginCreateBranchSheetAtRefish:selectedCommit inRepository:self.repository];
725+
}
724726
}
725727

726728
- (IBAction) createTag:(id)sender
727729
{
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+
}
732735
}
733736

734737
- (IBAction) showAddRemoteSheet:(id)sender
@@ -738,20 +741,23 @@ - (IBAction) showAddRemoteSheet:(id)sender
738741

739742
- (IBAction) merge:(id)sender
740743
{
741-
if (selectedCommit)
742-
[repository mergeWithRefish:selectedCommit];
744+
if (selectedCommit) {
745+
[self.repository mergeWithRefish:selectedCommit];
746+
}
743747
}
744748

745749
- (IBAction) cherryPick:(id)sender
746750
{
747-
if (selectedCommit)
748-
[repository cherryPickRefish:selectedCommit];
751+
if (selectedCommit) {
752+
[self.repository cherryPickRefish:selectedCommit];
753+
}
749754
}
750755

751756
- (IBAction) rebase:(id)sender
752757
{
753-
if (selectedCommit)
754-
[repository rebaseBranch:nil onRefish:selectedCommit];
758+
if (selectedCommit) {
759+
[self.repository rebaseBranch:nil onRefish:selectedCommit];
760+
}
755761
}
756762

757763
#pragma mark -

Classes/Controllers/PBGitIndexController.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#import "PBChangedFile.h"
1111
#import "PBGitRepository.h"
1212
#import "PBGitIndex.h"
13+
#import "PBGitWindowController.h"
1314

1415
#define FileChangesTableViewType @"GitFileChangedType"
1516

Classes/Controllers/PBGitSidebarController.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,13 @@
1616
@interface PBGitSidebarController : PBViewController<NSOutlineViewDelegate> {
1717
IBOutlet NSWindow *window;
1818
IBOutlet NSOutlineView *sourceView;
19-
IBOutlet NSView *sourceListControlsView;
2019
IBOutlet NSPopUpButton *actionButton;
2120
IBOutlet NSSegmentedControl *remoteControls;
2221

23-
NSMutableArray *items;
24-
2522
/* Specific things */
2623
PBSourceViewItem *stage;
2724

2825
PBSourceViewItem *branches, *remotes, *tags, *others, *submodules;
29-
30-
PBGitHistoryController *historyViewController;
31-
PBGitCommitController *commitViewController;
3226
}
3327

3428
- (void) selectStage;
@@ -41,9 +35,9 @@
4135

4236
- (void)setHistorySearch:(NSString *)searchString mode:(NSInteger)mode;
4337

44-
@property(readonly) NSMutableArray *items;
45-
@property(readonly) NSView *sourceListControlsView;
46-
@property(readonly) PBGitHistoryController *historyViewController;
47-
@property(readonly) PBGitCommitController *commitViewController;
38+
@property(nonatomic, strong, readonly) NSMutableArray *items;
39+
@property(nonatomic, strong) IBOutlet NSView *sourceListControlsView;
40+
@property(nonatomic, strong) IBOutlet PBGitHistoryController *historyViewController;
41+
@property(nonatomic, strong) IBOutlet PBGitCommitController *commitViewController;
4842

4943
@end

0 commit comments

Comments
 (0)