From 17df4e808a4c8fa19c2ca577b122133e96412a81 Mon Sep 17 00:00:00 2001 From: Pieter de Bie Date: Sat, 21 Jun 2008 14:05:55 +0200 Subject: [PATCH] PBGitRepository: search for git binary on more paths --- PBGitRepository.m | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/PBGitRepository.m b/PBGitRepository.m index bd9264c..6c6f927 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -28,11 +28,19 @@ static NSString* gitPath; // No explicit path. Try it with "which" gitPath = [PBEasyPipe outputForCommand:@"/usr/bin/which" withArgs:[NSArray arrayWithObject:@"git"]]; + if (gitPath.length > 0) + return; - if (gitPath.length == 0) { - NSLog(@"Git path not found. Defaulting to /opt/pieter/bin/git"); - gitPath = @"/opt/pieter/bin/git"; + // Still no path. Let's try some default locations. + NSArray* locations = [NSArray arrayWithObjects:@"/opt/local/bin/git", @"/sw/bin/git", @"/opt/git/bin/git", nil]; + for (NSString* location in locations) { + if ([[NSFileManager defaultManager] fileExistsAtPath:location]) { + gitPath = location; + return; + } } + + NSLog(@"Could not find a git binary!"); } + (PBGitRepository*) repositoryWithPath:(NSString*) path