diff --git a/PBCLIProxy.mm b/PBCLIProxy.mm index aed7967..6c66cd0 100644 --- a/PBCLIProxy.mm +++ b/PBCLIProxy.mm @@ -31,7 +31,8 @@ // work around an apparent bug with GC and Distributed Objects // I am not familiar with GC though, so perhaps I was doing something wrong. NSURL* url = [NSURL fileURLWithPath:[repositoryPath path]]; - if (id document = [[PBRepositoryDocumentController sharedDocumentController] openDocumentWithContentsOfURL:url display:YES error:nil]) { + NSArray* arguments = [NSArray arrayWithArray:args]; + if (id document = [[PBRepositoryDocumentController sharedDocumentController] openRepositoryAtLocation: url RevParseArgs: arguments]) { [NSApp activateIgnoringOtherApps:YES]; return YES; } diff --git a/PBGitRepository.h b/PBGitRepository.h index 98fe88e..5063a3d 100644 --- a/PBGitRepository.h +++ b/PBGitRepository.h @@ -32,6 +32,8 @@ extern NSString* PBGitRepositoryErrorDomain; + (NSURL*)gitDirForURL:(NSURL*)repositoryURL; + (NSURL*)baseDirForURL:(NSURL*)repositoryURL; +- (id) initWithURL: (NSURL*) path andArguments:(NSArray*) array; + @property (readonly) PBGitRevList* revisionList; @property (assign) NSArray* branches; @property (assign) NSString* currentBranch; diff --git a/PBGitRepository.m b/PBGitRepository.m index 43ada1c..b58c660 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -125,6 +125,16 @@ static NSString* gitPath; return success; } +- (id) initWithURL: (NSURL*) path andArguments:(NSArray*) array +{ + self = [self init]; + NSURL* gitDirURL = [PBGitRepository gitDirForURL:path]; + [self setFileURL: gitDirURL]; + [self readRefs]; + [self readCurrentBranch]; + revisionList = [[PBGitRevList alloc] initWithRepository:self andRevListParameters:array]; + return self; +} // The fileURL the document keeps is to the .git dir, but that’s pretty // useless for display in the window title bar, so we show the directory above - (NSString*)displayName diff --git a/PBRepositoryDocumentController.h b/PBRepositoryDocumentController.h index 8c9c040..b6d0afd 100644 --- a/PBRepositoryDocumentController.h +++ b/PBRepositoryDocumentController.h @@ -14,4 +14,5 @@ } +- (id) openRepositoryAtLocation:(NSURL*) url RevParseArgs:(NSArray*)args; @end diff --git a/PBRepositoryDocumentController.m b/PBRepositoryDocumentController.m index 0d255ad..11e908c 100644 --- a/PBRepositoryDocumentController.m +++ b/PBRepositoryDocumentController.m @@ -29,4 +29,18 @@ { [super noteNewRecentDocumentURL:[PBGitRepository baseDirForURL:url]]; } + +- (id) openRepositoryAtLocation:(NSURL*) url RevParseArgs:(NSArray*)args +{ + id document = [self documentForURL:url]; + if (!document) { + document = [[PBGitRepository alloc] initWithURL:url andArguments:args]; + [self addDocument:document]; + [document makeWindowControllers]; + } else { + // TODO: Add another revwalk specifier and show that. + } + [document showWindows]; + return document; +} @end