22
22
#import " PBGitRef.h"
23
23
#import " PBError.h"
24
24
#import " PBRepositoryDocumentController.h"
25
+ #import " PBGitRepositoryDocument.h"
25
26
#import " PBRefMenuItem.h"
26
27
#import " PBRemoteProgressSheet.h"
27
28
28
29
@implementation PBGitWindowController
29
30
30
- @synthesize repository;
31
31
@dynamic document;
32
32
33
- - (id ) initWithRepository : (PBGitRepository*) theRepository displayDefault : ( BOOL ) displayDefault
33
+ - (instancetype ) init
34
34
{
35
- if (!(self = [self initWithWindowNibName: @" RepositoryWindow" ]))
35
+ self = [super initWithWindowNibName: @" RepositoryWindow" ];
36
+ if (!self)
36
37
return nil ;
37
38
38
- self.repository = theRepository;
39
-
40
39
return self;
41
40
}
42
41
42
+ - (PBGitRepository *)repository
43
+ {
44
+ return [self .document repository ];
45
+ }
46
+
43
47
- (void )synchronizeWindowTitleWithDocumentName
44
48
{
45
49
[super synchronizeWindowTitleWithDocumentName ];
@@ -65,10 +69,10 @@ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem
65
69
{
66
70
if ([menuItem action ] == @selector (showCommitView: )) {
67
71
[menuItem setState: (contentController == sidebarController.commitViewController) ? YES : NO ];
68
- return ![repository isBareRepository ];
72
+ return ![self . repository isBareRepository ];
69
73
} else if ([menuItem action ] == @selector (showHistoryView: )) {
70
74
[menuItem setState: (contentController != sidebarController.commitViewController) ? YES : NO ];
71
- return ![repository isBareRepository ];
75
+ return ![self . repository isBareRepository ];
72
76
} else if (menuItem.action == @selector (fetchRemote: )) {
73
77
return [self validateMenuItem: menuItem remoteTitle: @" Fetch “%@ ”" plainTitle: @" Fetch" ];
74
78
} else if (menuItem.action == @selector (pullRemote: )) {
@@ -108,7 +112,8 @@ - (void) windowDidLoad
108
112
[[self window ] setFrameUsingName: @" GitX" ];
109
113
[[self window ] setRepresentedURL: self .repository.workingDirectoryURL];
110
114
111
- sidebarController = [[PBGitSidebarController alloc ] initWithRepository: repository superController: self ];
115
+ sidebarController = [[PBGitSidebarController alloc ] initWithRepository: self .repository superController: self ];
116
+
112
117
[[sidebarController view ] setFrame: [sourceSplitView bounds ]];
113
118
[sourceSplitView addSubview: [sidebarController view ]];
114
119
[sourceListControlsView addSubview: sidebarController.sourceListControlsView];
@@ -283,7 +288,7 @@ - (IBAction)addRemote:(id)sender
283
288
windowController: self ];
284
289
[progressSheet beginProgressSheetForBlock: ^{
285
290
NSError *error = nil ;
286
- BOOL success = [repository addRemote: remoteName withURL: remoteURL error: &error];
291
+ BOOL success = [self . repository addRemote: remoteName withURL: remoteURL error: &error];
287
292
return success ? nil : error;
288
293
} completionHandler: ^(NSError *error) {
289
294
if (error) {
@@ -292,7 +297,7 @@ - (IBAction)addRemote:(id)sender
292
297
}
293
298
294
299
// Now fetch that remote
295
- PBGitRef *remoteRef = [repository refForName: remoteName];
300
+ PBGitRef *remoteRef = [self . repository refForName: remoteName];
296
301
[self performFetchForRef: remoteRef];
297
302
}];
298
303
}];
@@ -309,7 +314,7 @@ - (void)performFetchForRef:(PBGitRef *)ref
309
314
310
315
[progressSheet beginProgressSheetForBlock: ^{
311
316
NSError *error = nil ;
312
- BOOL success = [repository fetchRemoteForRef: ref error: &error];
317
+ BOOL success = [self . repository fetchRemoteForRef: ref error: &error];
313
318
return (success ? nil : error);
314
319
} completionHandler: ^(NSError *error) {
315
320
if (error) {
@@ -345,7 +350,7 @@ - (void)performPullForBranch:(PBGitRef *)branchRef remote:(PBGitRef *)remoteRef
345
350
346
351
[progressSheet beginProgressSheetForBlock: ^{
347
352
NSError *error = nil ;
348
- BOOL success = [repository pullBranch: branchRef fromRemote: remoteRef rebase: rebase error: &error];
353
+ BOOL success = [self . repository pullBranch: branchRef fromRemote: remoteRef rebase: rebase error: &error];
349
354
return success ? nil : error;
350
355
} completionHandler: ^(NSError *error) {
351
356
if (error) {
@@ -397,7 +402,7 @@ - (void)performPushForBranch:(PBGitRef *)branchRef toRemote:(PBGitRef *)remoteRe
397
402
398
403
[progressSheet beginProgressSheetForBlock: ^{
399
404
NSError *error = nil ;
400
- BOOL success = [repository pushBranch: branchRef toRemote: remoteRef error: &error];
405
+ BOOL success = [self . repository pushBranch: branchRef toRemote: remoteRef error: &error];
401
406
return (success ? nil : error);
402
407
} completionHandler: ^(NSError *error) {
403
408
if (error) {
@@ -445,26 +450,26 @@ - (PBSourceViewItem *) selectedItem {
445
450
- (IBAction ) stashSave : (id ) sender
446
451
{
447
452
NSError *error = nil ;
448
- BOOL success = [repository stashSaveWithKeepIndex: NO error: &error];
453
+ BOOL success = [self . repository stashSaveWithKeepIndex: NO error: &error];
449
454
450
455
if (!success) [self showErrorSheet: error];
451
456
}
452
457
453
458
- (IBAction ) stashSaveWithKeepIndex : (id ) sender
454
459
{
455
460
NSError *error = nil ;
456
- BOOL success = [repository stashSaveWithKeepIndex: YES error: &error];
461
+ BOOL success = [self . repository stashSaveWithKeepIndex: YES error: &error];
457
462
458
463
if (!success) [self showErrorSheet: error];
459
464
}
460
465
461
466
- (IBAction ) stashPop : (id ) sender
462
467
{
463
- if ([repository.stashes count ] <= 0 ) return ;
468
+ if ([self . repository.stashes count ] <= 0 ) return ;
464
469
465
- PBGitStash * latestStash = [repository.stashes objectAtIndex: 0 ];
470
+ PBGitStash * latestStash = [self . repository.stashes objectAtIndex: 0 ];
466
471
NSError *error = nil ;
467
- BOOL success = [repository stashPop: latestStash error: &error];
472
+ BOOL success = [self . repository stashPop: latestStash error: &error];
468
473
469
474
if (!success) [self showErrorSheet: error];
470
475
}
@@ -513,7 +518,7 @@ - (IBAction) refresh:(id)sender
513
518
514
519
- (void ) createBranch : (id )sender
515
520
{
516
- PBGitRef *currentRef = [repository.currentBranch ref ];
521
+ PBGitRef *currentRef = [self . repository.currentBranch ref ];
517
522
518
523
id <PBGitRefish> refish = nil ;
519
524
if ([sender isKindOfClass: [PBRefMenuItem class ]]) {
@@ -559,7 +564,7 @@ - (void) createTag:(PBRefMenuItem *)sender
559
564
if (selectedCommit)
560
565
refish = selectedCommit;
561
566
else
562
- refish = repository.currentBranch .ref ;
567
+ refish = self. repository .currentBranch .ref ;
563
568
}
564
569
565
570
[PBCreateTagSheet beginSheetWithRefish: refish windowController: self completionHandler: ^(PBCreateTagSheet *sheet, NSModalResponse returnCode) {
0 commit comments