Add branch control to the PBGitRepository

This allows you to add and select specific branches
This commit is contained in:
Pieter de Bie
2008-09-12 17:55:45 +02:00
parent 81d80cbbe4
commit dea6a77d02
2 changed files with 22 additions and 2 deletions
+5 -2
View File
@@ -8,12 +8,13 @@
#import <Cocoa/Cocoa.h>
#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
+17
View File
@@ -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"];