Skip to content

Commit

Permalink
PBGitRepository: Add method to remove branch
Browse files Browse the repository at this point in the history
This adds a removeBranch method similar to the addBranch method. It
calls these methods when a branch is created/deleted in the UI, avoiding
the cost of simply calling refresh afterwards.

Signed-off-by: Johannes Gilger <heipei@hackvalue.de>
  • Loading branch information
heipei authored and Pieter de Bie committed Jun 6, 2009
1 parent 7b63935 commit 64b977e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions PBGitRepository.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ extern NSString* PBGitRepositoryErrorDomain;

- (void) readCurrentBranch;
- (PBGitRevSpecifier*) addBranch: (PBGitRevSpecifier*) rev;
- (BOOL)removeBranch:(PBGitRevSpecifier *)rev;

- (NSString*) parseSymbolicReference:(NSString*) ref;
- (NSString*) parseReference:(NSString*) ref;
Expand Down
13 changes: 13 additions & 0 deletions PBGitRepository.m
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,19 @@ - (PBGitRevSpecifier*) addBranch: (PBGitRevSpecifier*) rev
[self didChangeValueForKey:@"branches"];
return rev;
}

- (BOOL)removeBranch:(PBGitRevSpecifier *)rev
{
for (PBGitRevSpecifier *r in branches) {
if ([rev isEqualTo:r]) {
[self willChangeValueForKey:@"branches"];
[branches removeObject:r];
[self didChangeValueForKey:@"branches"];
return TRUE;
}
}
return FALSE;
}

- (void) readCurrentBranch
{
Expand Down
4 changes: 2 additions & 2 deletions PBRefController.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ - (void) removeRef:(PBRefMenuItem *) sender
NSLog(@"Removing ref failed!");
return;
}

[historyController.repository removeBranch:[[PBGitRevSpecifier alloc] initWithRef:[sender ref]]];
[[sender commit] removeRef:[sender ref]];
[commitController rearrangeObjects];
}
Expand Down Expand Up @@ -208,7 +208,7 @@ -(void)saveSheet:(id) sender
[errorMessage setStringValue:@"Branch exists"];
return;
}

[historyController.repository addBranch:[[PBGitRevSpecifier alloc] initWithRef:[PBGitRef refFromString:branchName]]];
[self closeSheet:sender];
[commit addRef:[PBGitRef refFromString:branchName]];
[commitController rearrangeObjects];
Expand Down

0 comments on commit 64b977e

Please sign in to comment.