Skip to content

Commit 6690368

Browse files
committed
Merge remote-tracking branch 'tiennou/master'
2 parents bf9a81d + 64045a9 commit 6690368

Some content is hidden

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

65 files changed

+3286
-8822
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[submodule "objective-git"]
22
path = objective-git
3-
url = git://github.com/rowanj/objective-git.git
3+
url = git://github.com/libgit2/objective-git.git
44
[submodule "Sparkle"]
55
path = Sparkle
66
url = git://github.com/sparkle-project/Sparkle.git

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: objective-c
2+
xcode_project: GitX.xcodeproj
3+
xcode_scheme: Release
4+
osx_image: xcode7.1
5+
before_install:
6+
- objective-git/script/bootstrap

Classes/Controllers/ApplicationController.m

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

99
#import "ApplicationController.h"
10+
#import "PBRepositoryDocumentController.h"
1011
#import "PBGitRevisionCell.h"
1112
#import "PBGitWindowController.h"
1213
#import "PBServicesController.h"
@@ -22,6 +23,9 @@
2223

2324
static OpenRecentController* recentsDialog = nil;
2425

26+
@interface ApplicationController () <SUUpdaterDelegate>
27+
@end
28+
2529
@implementation ApplicationController
2630

2731
- (ApplicationController*)init
@@ -67,6 +71,20 @@ - (void)registerServices
6771
}
6872
}
6973

74+
- (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename {
75+
NSURL *repository = [NSURL fileURLWithPath:filename];
76+
NSError *error = nil;
77+
NSDocument *doc = [[PBRepositoryDocumentController sharedDocumentController] openDocumentWithContentsOfURL:repository
78+
display:YES
79+
error:&error];
80+
if (!doc) {
81+
NSLog(@"Error opening repository \"%@\": %@", repository.path, error);
82+
return NO;
83+
}
84+
85+
return YES;
86+
}
87+
7088
- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender
7189
{
7290
if(!started || [[[NSDocumentController sharedDocumentController] documents] count])

Classes/Controllers/OpenRecentController.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ - (IBAction) tableDoubleClick:(id)sender
7676
{
7777
[self changeSelection:self];
7878
if(selectedResult != nil) {
79-
[[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:selectedResult
80-
display:YES
81-
error:nil];
79+
[[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:selectedResult display:YES completionHandler:^(NSDocument * _Nullable document, BOOL documentWasAlreadyOpen, NSError * _Nullable error) {
80+
81+
}];
8282
}
8383
[self hide];
8484
}
@@ -87,9 +87,9 @@ - (BOOL)control:(NSControl*)control textView:(NSTextView*)textView doCommandBySe
8787
BOOL result = NO;
8888
if (commandSelector == @selector(insertNewline:)) {
8989
if(selectedResult != nil) {
90-
[[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:selectedResult
91-
display:YES
92-
error:nil];
90+
[[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:selectedResult display:YES completionHandler:^(NSDocument * _Nullable document, BOOL documentWasAlreadyOpen, NSError * _Nullable error) {
91+
92+
}];
9393
}
9494
[self hide];
9595
// [searchWindow makeKeyAndOrderFront: nil];

Classes/Controllers/PBDiffWindowController.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
1010

1111
@class PBGitCommit;
1212

13-
@interface PBDiffWindowController : NSWindowController {
14-
NSString *diff;
15-
}
13+
@interface PBDiffWindowController : NSWindowController
1614

17-
+ (void) showDiffWindowWithFiles:(NSArray *)filePaths fromCommit:(PBGitCommit *)startCommit diffCommit:(PBGitCommit *)diffCommit;
18-
- (id) initWithDiff:(NSString *)diff;
15+
+ (void)showDiff:(NSString *)diff;
16+
+ (void)showDiffWindowWithFiles:(NSArray *)filePaths fromCommit:(PBGitCommit *)startCommit diffCommit:(PBGitCommit *)diffCommit;
17+
- (instancetype)initWithDiff:(NSString *)diff;
1918

2019
@property (readonly) NSString *diff;
2120
@end

Classes/Controllers/PBDiffWindowController.m

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,47 +13,29 @@
1313

1414

1515
@implementation PBDiffWindowController
16-
@synthesize diff;
1716

18-
- (id) initWithDiff:(NSString *)aDiff
17+
+ (void)showDiff:(NSString *)diff
1918
{
20-
self = [super initWithWindowNibName:@"PBDiffWindow"];
21-
22-
if (self)
23-
diff = aDiff;
24-
25-
return self;
19+
PBDiffWindowController *diffController = [[self alloc] initWithDiff:diff];
20+
[diffController showWindow:self];
2621
}
2722

28-
29-
+ (void) showDiffWindowWithFiles:(NSArray *)filePaths fromCommit:(PBGitCommit *)startCommit diffCommit:(PBGitCommit *)diffCommit
23+
+ (void)showDiffWindowWithFiles:(NSArray *)filePaths fromCommit:(PBGitCommit *)startCommit diffCommit:(PBGitCommit *)diffCommit
3024
{
31-
if (!startCommit)
32-
return;
33-
34-
if (!diffCommit)
35-
diffCommit = [startCommit.repository headCommit];
36-
37-
NSString *commitSelector = [NSString stringWithFormat:@"%@..%@", startCommit.SHA, diffCommit.SHA];
38-
NSMutableArray *arguments = [NSMutableArray arrayWithObjects:@"diff", @"--no-ext-diff", commitSelector, nil];
25+
NSParameterAssert(startCommit != nil);
26+
NSString *diff = [startCommit.repository performDiff:startCommit against:diffCommit forFiles:filePaths];
3927

40-
if (![PBGitDefaults showWhitespaceDifferences])
41-
[arguments insertObject:@"-w" atIndex:1];
42-
43-
if (filePaths) {
44-
[arguments addObject:@"--"];
45-
[arguments addObjectsFromArray:filePaths];
46-
}
28+
[PBDiffWindowController showDiff:[diff copy]];
29+
}
4730

48-
int retValue;
49-
NSString *diff = [startCommit.repository outputInWorkdirForArguments:arguments retValue:&retValue];
50-
if (retValue) {
51-
NSLog(@"diff failed with retValue: %d for command: '%@' output: '%@'", retValue, [arguments componentsJoinedByString:@" "], diff);
52-
return;
53-
}
31+
- (id)initWithDiff:(NSString *)aDiff
32+
{
33+
self = [super initWithWindowNibName:@"PBDiffWindow"];
34+
if (!self) return nil;
5435

55-
PBDiffWindowController *diffController = [[PBDiffWindowController alloc] initWithDiff:[diff copy]];
56-
[diffController showWindow:nil];
36+
_diff = aDiff;
37+
38+
return self;
5739
}
5840

5941

Classes/Controllers/PBGitHistoryController.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@
7979
- (NSMenu *)contextMenuForTreeView;
8080
- (NSArray *)menuItemsForPaths:(NSArray *)paths;
8181
- (void)showCommitsFromTree:(id)sender;
82-
- (void)showInFinderAction:(id)sender;
83-
- (void)openFilesAction:(id)sender;
8482

8583
// Repository Methods
8684
- (IBAction) createBranch:(id)sender;

Classes/Controllers/PBGitHistoryController.m

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ - (void) checkoutFiles:(id)sender
594594

595595
- (void) diffFilesAction:(id)sender
596596
{
597+
/* TODO: Move that to the document */
597598
[PBDiffWindowController showDiffWindowWithFiles:[sender representedObject] fromCommit:self.selectedCommits.firstObject diffCommit:nil];
598599
}
599600

@@ -673,32 +674,6 @@ - (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)pr
673674
return [splitView frame].size.height - [splitView dividerThickness] - historySplitView.bottomViewMin;
674675
}
675676

676-
// while the user resizes the window keep the upper (history) view constant and just resize the lower view
677-
// unless the lower view gets too small
678-
- (void)splitView:(NSSplitView *)splitView resizeSubviewsWithOldSize:(NSSize)oldSize
679-
{
680-
NSRect newFrame = [splitView frame];
681-
682-
float dividerThickness = [splitView dividerThickness];
683-
684-
NSView *upperView = [[splitView subviews] objectAtIndex:0];
685-
NSRect upperFrame = [upperView frame];
686-
upperFrame.size.width = newFrame.size.width;
687-
688-
if ((newFrame.size.height - upperFrame.size.height - dividerThickness) < historySplitView.bottomViewMin) {
689-
upperFrame.size.height = newFrame.size.height - historySplitView.bottomViewMin - dividerThickness;
690-
}
691-
692-
NSView *lowerView = [[splitView subviews] objectAtIndex:1];
693-
NSRect lowerFrame = [lowerView frame];
694-
lowerFrame.origin.y = upperFrame.size.height + dividerThickness;
695-
lowerFrame.size.height = newFrame.size.height - lowerFrame.origin.y;
696-
lowerFrame.size.width = newFrame.size.width;
697-
698-
[upperView setFrame:upperFrame];
699-
[lowerView setFrame:lowerFrame];
700-
}
701-
702677
// NSSplitView does not save and restore the position of the SplitView correctly so do it manually
703678
- (void)saveSplitViewPosition
704679
{
@@ -841,8 +816,8 @@ - (NSRect)previewPanel:(id)panel sourceFrameOnScreenForPreviewItem:(id <QLPrevie
841816
}
842817

843818
// convert icon rect to screen coordinates
844-
iconRect = [fileBrowser convertRectToBase:iconRect];
845-
iconRect.origin = [[fileBrowser window] convertBaseToScreen:iconRect.origin];
819+
iconRect = [fileBrowser.window.contentView convertRect:iconRect fromView:fileBrowser];
820+
iconRect = [fileBrowser.window convertRectToScreen:iconRect];
846821

847822
return iconRect;
848823
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// PBGitRepositoryDocument.h
3+
// GitX
4+
//
5+
// Created by Etienne on 31/07/2014.
6+
//
7+
//
8+
9+
#import <Cocoa/Cocoa.h>
10+
11+
@class PBGitRepository;
12+
@class PBGitRevSpecifier;
13+
14+
extern NSString *PBGitRepositoryDocumentType;
15+
16+
@interface PBGitRepositoryDocument : NSDocument
17+
18+
@property (nonatomic, strong, readonly) PBGitRepository *repository;
19+
20+
21+
// Scripting Bridge
22+
- (void)findInModeScriptCommand:(NSScriptCommand *)command;
23+
24+
// Responder
25+
- (IBAction)showInFinderAction:(id)sender;
26+
- (IBAction)openFilesAction:(id)sender;
27+
28+
- (IBAction)showCommitView:(id)sender;
29+
- (IBAction)showHistoryView:(id)sender;
30+
31+
- (void)selectRevisionSpecifier:(PBGitRevSpecifier *)specifier;
32+
33+
@end

0 commit comments

Comments
 (0)