Skip to content

Commit ee67330

Browse files
committed
Merge pull request brotherbard#74 from Uncommon/stash
Show stash contents when selected in the sidebar
2 parents 87bc0d8 + 0d89d91 commit ee67330

13 files changed

+1419
-33
lines changed

Commands/PBCommandFactory.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
#import "PBGitRepository.h"
10+
#import "PBPresentable.h"
1011

1112
@protocol PBCommandFactory
1213
+ (NSArray *) commandsForObject:(id<PBPresentable>) object repository:(PBGitRepository *) repository;

GitX.xcodeproj/project.pbxproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@
138138
D8FDDA6F114335E8005647F6 /* PBGitSVStageItem.m in Sources */ = {isa = PBXBuildFile; fileRef = D8FDDA67114335E8005647F6 /* PBGitSVStageItem.m */; };
139139
D8FDDA70114335E8005647F6 /* PBGitSVTagItem.m in Sources */ = {isa = PBXBuildFile; fileRef = D8FDDA69114335E8005647F6 /* PBGitSVTagItem.m */; };
140140
D8FDDBF41143F318005647F6 /* AddRemote.png in Resources */ = {isa = PBXBuildFile; fileRef = D8FDDBF31143F318005647F6 /* AddRemote.png */; };
141+
DDB8FE0113998CE2001A9EE2 /* PBStashContentController.m in Sources */ = {isa = PBXBuildFile; fileRef = DDB8FE0013998CE2001A9EE2 /* PBStashContentController.m */; };
142+
DDB8FEC413999C24001A9EE2 /* PBStashContentView.xib in Resources */ = {isa = PBXBuildFile; fileRef = DDB8FEC313999C24001A9EE2 /* PBStashContentView.xib */; };
141143
F50FE0E30E07BE9600854FCD /* PBGitRevisionCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F50FE0E20E07BE9600854FCD /* PBGitRevisionCell.m */; };
142144
F513085B0E0740F2000C8BCD /* PBQLOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = F513085A0E0740F2000C8BCD /* PBQLOutlineView.m */; };
143145
F5140DC90E8A8EB20091E9F3 /* RoundedRectangle.m in Sources */ = {isa = PBXBuildFile; fileRef = F5140DC80E8A8EB20091E9F3 /* RoundedRectangle.m */; };
@@ -425,6 +427,9 @@
425427
D8FDDA69114335E8005647F6 /* PBGitSVTagItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitSVTagItem.m; sourceTree = "<group>"; };
426428
D8FDDA7311433634005647F6 /* PBSourceViewItems.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBSourceViewItems.h; sourceTree = "<group>"; };
427429
D8FDDBF31143F318005647F6 /* AddRemote.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = AddRemote.png; path = Images/AddRemote.png; sourceTree = "<group>"; };
430+
DDB8FDFF13998CE2001A9EE2 /* PBStashContentController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBStashContentController.h; sourceTree = "<group>"; };
431+
DDB8FE0013998CE2001A9EE2 /* PBStashContentController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBStashContentController.m; sourceTree = "<group>"; };
432+
DDB8FEC313999C24001A9EE2 /* PBStashContentView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PBStashContentView.xib; sourceTree = "<group>"; };
428433
F50FE0E10E07BE9600854FCD /* PBGitRevisionCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitRevisionCell.h; sourceTree = "<group>"; };
429434
F50FE0E20E07BE9600854FCD /* PBGitRevisionCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitRevisionCell.m; sourceTree = "<group>"; };
430435
F51308590E0740F2000C8BCD /* PBQLOutlineView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBQLOutlineView.h; sourceTree = "<group>"; };
@@ -765,6 +770,7 @@
765770
F5E424100EA3E4D60046E362 /* PBDiffWindow.xib */,
766771
F52BCE020E84208300AA3741 /* PBGitHistoryView.xib */,
767772
F59116E50E843BB50072CCB1 /* PBGitCommitView.xib */,
773+
DDB8FEC313999C24001A9EE2 /* PBStashContentView.xib */,
768774
D85B939210E3D8B4007F3C28 /* PBCreateBranchSheet.xib */,
769775
D889EB3010E6BCBB00F08413 /* PBCreateTagSheet.xib */,
770776
D8C1B77110E875CF009B7F8B /* PBRemoteProgressSheet.xib */,
@@ -939,6 +945,8 @@
939945
77C8280C06725ACE000B614F /* ApplicationController.m */,
940946
93CB42C00EAB7B2200530609 /* PBGitDefaults.h */,
941947
93CB42C10EAB7B2200530609 /* PBGitDefaults.m */,
948+
DDB8FDFF13998CE2001A9EE2 /* PBStashContentController.h */,
949+
DDB8FE0013998CE2001A9EE2 /* PBStashContentController.m */,
942950
F57CC43F0E05E496000472E2 /* PBGitWindowController.h */,
943951
F57CC4400E05E496000472E2 /* PBGitWindowController.m */,
944952
911111F60E594F3F00BF76B4 /* PBRepositoryDocumentController.h */,
@@ -1286,6 +1294,7 @@
12861294
316E7202131EE9C600AFBB36 /* list_Template.png in Resources */,
12871295
316E7203131EE9C600AFBB36 /* sidebar_Template.png in Resources */,
12881296
65D58BC4132D27A8003F7290 /* PBResetSheet.xib in Resources */,
1297+
DDB8FEC413999C24001A9EE2 /* PBStashContentView.xib in Resources */,
12891298
);
12901299
runOnlyForDeploymentPostprocessing = 0;
12911300
};
@@ -1447,6 +1456,7 @@
14471456
217FF0BE12A1CB3E00785A65 /* PBRevealWithFinderCommand.m in Sources */,
14481457
65D58BC7132D48C2003F7290 /* PBResetSheet.m in Sources */,
14491458
31776089133569350025876E /* SearchWebView.m in Sources */,
1459+
DDB8FE0113998CE2001A9EE2 /* PBStashContentController.m in Sources */,
14501460
);
14511461
runOnlyForDeploymentPostprocessing = 0;
14521462
};

PBGitHistoryController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
IBOutlet PBCommitList* commitList;
3434
IBOutlet NSSplitView *historySplitView;
3535
IBOutlet PBWebHistoryController *webHistoryController;
36-
QLPreviewPanel* previewPanel;
36+
QLPreviewPanel* previewPanel;
3737
IBOutlet PBHistorySearchController *searchController;
3838
IBOutlet GLFileView *fileView;
3939

PBGitHistoryController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ - (void)awakeFromNib
9494

9595

9696
[super awakeFromNib];
97-
[fileBrowser setDelegate:self];
97+
[fileBrowser setDelegate:self];
9898
}
9999

100100
- (void)updateKeys
@@ -414,7 +414,7 @@ - (IBAction) refresh:(id)sender
414414

415415
- (void) updateView
416416
{
417-
[self refresh: nil];
417+
[self refresh: nil];
418418
[self updateKeys];
419419
}
420420

PBGitRepository.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
#import "PBGitConfig.h"
1313
#import "PBGitRefish.h"
1414

15-
#import "PBStashController.h"
16-
#import "PBGitResetController.h"
17-
#import "PBSubmoduleController.h"
18-
1915
extern NSString* PBGitRepositoryErrorDomain;
2016
typedef enum branchFilterTypes {
2117
kGitXAllBranchesFilter = 0,
@@ -42,7 +38,9 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) {
4238

4339
@class PBGitWindowController;
4440
@class PBGitCommit;
45-
@class NSString;
41+
@class PBGitResetController;
42+
@class PBStashController;
43+
@class PBSubmoduleController;
4644

4745
@interface PBGitRepository : NSDocument {
4846
PBGitHistoryList* revisionList;

PBGitRepository.m

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@
1212
#import "PBGitBinary.h"
1313

1414
#import "NSFileHandleExt.h"
15+
#import "GitXScriptingConstants.h"
1516
#import "PBEasyPipe.h"
17+
#import "PBGitDefaults.h"
1618
#import "PBGitRef.h"
17-
#import "PBGitRevSpecifier.h"
18-
#import "PBRemoteProgressSheet.h"
19+
#import "PBGitResetController.h"
1920
#import "PBGitRevList.h"
20-
#import "PBGitDefaults.h"
21-
#import "GitXScriptingConstants.h"
21+
#import "PBGitRevSpecifier.h"
2222
#import "PBHistorySearchController.h"
23+
#import "PBRemoteProgressSheet.h"
24+
#import "PBStashController.h"
25+
#import "PBSubmoduleController.h"
2326

2427
#import "PBGitStash.h"
2528
#import "PBGitSubmodule.h"

PBGitSidebarController.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
@class PBSourceViewItem;
1313
@class PBGitHistoryController;
1414
@class PBGitCommitController;
15+
@class PBStashContentController;
1516

1617
@interface PBGitSidebarController : PBViewController PROTOCOL_10_6(NSOutlineViewDelegate, NSMenuDelegate){
1718
IBOutlet NSWindow *window;
@@ -33,6 +34,7 @@
3334

3435
PBGitHistoryController *historyViewController;
3536
PBGitCommitController *commitViewController;
37+
PBStashContentController *stashViewController;
3638
}
3739

3840
- (void) selectStage;
@@ -54,5 +56,6 @@
5456
@property(readonly) NSView *sourceListControlsView;
5557
@property(readonly) PBGitHistoryController *historyViewController;
5658
@property(readonly) PBGitCommitController *commitViewController;
59+
@property(readonly) PBStashContentController *stashViewController;
5760

5861
@end

PBGitSidebarController.m

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#import "PBCommandMenuItem.h"
2424
#import "PBGitStash.h"
2525
#import "PBGitSubmodule.h"
26+
#import "PBSubmoduleController.h"
27+
#import "PBStashContentController.h"
2628

2729
static NSString * const kObservingContextStashes = @"stashesChanged";
2830
static NSString * const kObservingContextSubmodules = @"submodulesChanged";
@@ -42,6 +44,7 @@ @implementation PBGitSidebarController
4244
@synthesize sourceListControlsView;
4345
@synthesize historyViewController;
4446
@synthesize commitViewController;
47+
@synthesize stashViewController;
4548

4649
- (id)initWithRepository:(PBGitRepository *)theRepository superController:(PBGitWindowController *)controller
4750
{
@@ -60,6 +63,9 @@ - (void)awakeFromNib
6063

6164
historyViewController = [[PBGitHistoryController alloc] initWithRepository:repository superController:superController];
6265
commitViewController = [[PBGitCommitController alloc] initWithRepository:repository superController:superController];
66+
stashViewController = [[PBStashContentController alloc] initWithRepository:repository superController:superController];
67+
68+
[stashViewController loadView];
6369

6470
[repository addObserver:self forKeyPath:@"refs" options:0 context:@"updateRefs"];
6571
[repository addObserver:self forKeyPath:@"currentBranch" options:0 context:@"currentBranchChange"];
@@ -83,6 +89,7 @@ - (void)closeView
8389
{
8490
[historyViewController closeView];
8591
[commitViewController closeView];
92+
[stashViewController closeView];
8693

8794
[repository removeObserver:self forKeyPath:@"currentBranch"];
8895
[repository removeObserver:self forKeyPath:@"branches"];
@@ -318,6 +325,12 @@ - (void)outlineViewSelectionDidChange:(NSNotification *)notification
318325
[PBGitDefaults setShowStageView:YES];
319326
}
320327

328+
if ([item parent] == stashes) {
329+
[superController changeContentController:stashViewController];
330+
[PBGitDefaults setShowStageView:NO];
331+
[stashViewController showStash:(PBGitStash*)[(PBGitMenuItem*)item sourceObject]];
332+
}
333+
321334
[self updateActionMenu];
322335
[self updateRemoteControls];
323336
}

PBRefController.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#import "PBCreateTagSheet.h"
1414
#import "PBGitDefaults.h"
1515
#import "PBDiffWindowController.h"
16+
#import "PBGitResetController.h"
1617

1718
#import "PBArgumentPickerController.h"
1819

PBStashContentController.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// PBStashContentController.h
3+
// GitX
4+
//
5+
// Created by David Catmull on 20-06-11.
6+
// Copyright 2011. All rights reserved.
7+
//
8+
9+
#import "PBViewController.h"
10+
#import "PBWebHistoryController.h"
11+
12+
@class PBGitStash;
13+
@class PBWebStashController;
14+
15+
// Controls the view displaying a stash diff
16+
@interface PBStashContentController : PBViewController {
17+
IBOutlet id webView;
18+
IBOutlet PBWebHistoryController *webController;
19+
}
20+
21+
- (void) showStash:(PBGitStash*)stash;
22+
23+
@end

PBStashContentController.m

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// PBStashContentController.h
3+
// GitX
4+
//
5+
// Created by David Catmull on 20-06-11.
6+
// Copyright 2011. All rights reserved.
7+
//
8+
9+
#import "PBStashContentController.h"
10+
#import "PBGitDefaults.h"
11+
#import "PBGitStash.h"
12+
13+
@implementation PBStashContentController
14+
15+
- (void) awakeFromNib
16+
{
17+
[webController setRepository:repository];
18+
}
19+
20+
- (void) showStash:(PBGitStash*)stash
21+
{
22+
NSString *stashRef = [NSString stringWithFormat:@"refs/%@", [stash name]];
23+
NSString *stashSha = [repository shaForRef:[PBGitRef refFromString:stashRef]];
24+
PBGitCommit *commit = [PBGitCommit commitWithRepository:repository andSha:stashSha];
25+
26+
[webController changeContentTo:commit];
27+
}
28+
29+
@end

0 commit comments

Comments
 (0)