From 8a399c0793f8122e65babd89702762a62cf35364 Mon Sep 17 00:00:00 2001 From: Pieter de Bie Date: Sat, 1 Nov 2008 21:57:13 +0100 Subject: [PATCH] GitCommit: Add a 'removeRef' function The ref functionality is somewhat weird right now, in that some parts of the code require a nil array when there are no refs. So, we add a good removeRef accessor to keep track of this --- PBGitCommit.h | 1 + PBGitCommit.m | 10 ++++++++++ PBRefController.m | 5 +---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/PBGitCommit.h b/PBGitCommit.h index 75e74194b..f95829a23 100644 --- a/PBGitCommit.h +++ b/PBGitCommit.h @@ -27,6 +27,7 @@ - initWithRepository:(PBGitRepository*) repo andSha:(NSString*) sha; - (void)addRef:(id)ref; +- (void)removeRef:(id)ref; @property (copy) NSString* sha; @property (copy) NSString* subject; diff --git a/PBGitCommit.m b/PBGitCommit.m index 385bed543..8e9a50dac 100644 --- a/PBGitCommit.m +++ b/PBGitCommit.m @@ -70,6 +70,16 @@ - (void)addRef:(id)ref [self.refs addObject:ref]; } +- (void)removeRef:(id)ref +{ + if (!self.refs) + return; + + [refs removeObject:ref]; + if ([refs count] == 0) + refs = NULL; +} + + (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector { return NO; diff --git a/PBRefController.m b/PBRefController.m index 960562580..313f67331 100644 --- a/PBRefController.m +++ b/PBRefController.m @@ -88,10 +88,7 @@ - (BOOL)tableView:(NSTableView *)aTableView return NO; [dropCommit addRef:ref]; - - [oldCommit.refs removeObject:ref]; - if ([oldCommit.refs count] == 0) - oldCommit.refs = NULL; + [oldCommit removeRef:ref]; [commitController rearrangeObjects]; [aTableView needsToDrawRect:[aTableView rectOfRow:oldRow]];