Skip to content

Commit e60ae84

Browse files
committed
Convert gitDirForURL to use ObjectiveGit instead of piped command
1 parent a031999 commit e60ae84

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

PBGitRepository.m

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,28 +58,12 @@ - (BOOL) isBareRepository
5858

5959
+ (NSURL *)gitDirForURL:(NSURL *)repositoryURL;
6060
{
61-
if (![PBGitBinary path])
62-
return nil;
63-
64-
if ([self isBareRepository:repositoryURL])
65-
return repositoryURL;
66-
67-
NSString* repositoryPath = [repositoryURL path];
68-
// Use rev-parse to find the .git dir for the repository being opened
69-
int retValue = 1;
70-
NSString *newPath = [PBEasyPipe outputForCommand:[PBGitBinary path] withArgs:[NSArray arrayWithObjects:@"rev-parse", @"--git-dir", nil] inDir:repositoryPath retValue:&retValue];
71-
if (retValue) {
72-
// The current directory does not contain a git repository
73-
return nil;
61+
NSError* repoInitError;
62+
GTRepository* objgRepo = [[GTRepository alloc] initWithURL:repositoryURL error:&repoInitError];
63+
if (objgRepo != NULL) {
64+
NSURL* repoPath = objgRepo.fileUrl;
65+
return repoPath;
7466
}
75-
76-
if ([newPath isEqualToString:@".git"])
77-
return [NSURL fileURLWithPath:[repositoryPath stringByAppendingPathComponent:@".git"]];
78-
if ([newPath isEqualToString:@"."])
79-
return [NSURL fileURLWithPath:repositoryPath];
80-
if ([newPath length] > 0)
81-
return [NSURL fileURLWithPath:newPath];
82-
8367
return nil;
8468
}
8569

0 commit comments

Comments
 (0)