diff --git a/PBGitRepository.m b/PBGitRepository.m index c55582b..fd4ca25 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -118,8 +118,8 @@ static NSString* gitPath; if (success) { [self readRefs]; - [self readCurrentBranch]; revisionList = [[PBGitRevList alloc] initWithRepository:self]; + [self readCurrentBranch]; } } @@ -133,8 +133,10 @@ static NSString* gitPath; [self setFileURL: gitDirURL]; [self readRefs]; - [self selectBranch: [self addBranch: rev]]; + revisionList = [[PBGitRevList alloc] initWithRepository:self]; + [self selectBranch: [self addBranch: rev]]; + return self; } // The fileURL the document keeps is to the .git dir, but that’s pretty diff --git a/PBGitRevList.m b/PBGitRevList.m index aab5efe..8bdc268 100644 --- a/PBGitRevList.m +++ b/PBGitRevList.m @@ -18,8 +18,6 @@ - initWithRepository: (id) repo { repository = repo; - - [self readCommits]; [repository addObserver:self forKeyPath:@"currentBranch" options:0 context:nil]; return self; @@ -31,10 +29,13 @@ // we can check if the current branch is the same as the previous one // and in that case we don't have to reload the revision list. - // If no branch was selected, use the current HEAD + // If no branch is selected, don't do anything + if (![repository currentBranch] || [[repository currentBranch] count] == 0) + return; + NSArray* selectedBranches = [[repository branches] objectsAtIndexes: [repository currentBranch]]; - // Apparently, we don't have a current branch yet. Let's skip it. + // Apparently, The selected index does not exist.. don't do anything if ([selectedBranches count] == 0) return;