diff --git a/PBGitRepository.h b/PBGitRepository.h index 63c4972..021378d 100644 --- a/PBGitRepository.h +++ b/PBGitRepository.h @@ -8,12 +8,13 @@ #import #import "PBGitRevList.h" +#import "PBGitRevSpecifier.h" extern NSString* PBGitRepositoryErrorDomain; @interface PBGitRepository : NSDocument { PBGitRevList* revisionList; - NSArray* branches; + NSMutableArray* branches; NSIndexSet* currentBranch; NSDictionary* refs; } @@ -25,6 +26,8 @@ extern NSString* PBGitRepositoryErrorDomain; - (void) readRefs; - (void) readCurrentBranch; +- (void) addBranch: (PBGitRevSpecifier*) rev; +- (void) selectBranch: (PBGitRevSpecifier*) rev; - (NSString*) parseSymbolicReference:(NSString*) ref; - (NSString*) parseReference:(NSString*) ref; @@ -35,7 +38,7 @@ extern NSString* PBGitRepositoryErrorDomain; - (id) initWithURL: (NSURL*) path andArguments:(NSArray*) array; @property (retain) PBGitRevList* revisionList; -@property (assign) NSArray* branches; +@property (assign) NSMutableArray* branches; @property (assign) NSIndexSet* currentBranch; @property (assign) NSDictionary* refs; @end diff --git a/PBGitRepository.m b/PBGitRepository.m index e23f0a4..6a15b55 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -183,6 +183,23 @@ static NSString* gitPath; self.refs = newRefs; } +- (void) addBranch: (PBGitRevSpecifier*) rev +{ + [branches addObject: rev]; +} + +- (void) selectBranch: (PBGitRevSpecifier*) rev +{ + int i; + for (i = 0; i < [branches count]; i++) { + PBGitRevSpecifier* aRev = [branches objectAtIndex:i]; + if (rev == aRev) { + self.currentBranch = [NSIndexSet indexSetWithIndex:i]; + return; + } + } +} + - (void) readCurrentBranch { NSString* branch = [self parseSymbolicReference: @"HEAD"];