Skip to content

Commit

Permalink
GitCommit: Add a 'removeRef' function
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pieter committed Nov 1, 2008
1 parent 23c9186 commit 8a399c0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions PBGitCommit.h
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions PBGitCommit.m
Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions PBRefController.m
Expand Up @@ -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]];
Expand Down

0 comments on commit 8a399c0

Please sign in to comment.