Permalink
Browse files

Fix branch reloading

This fixes a regression in 86606ef, where the branches array was
created anew every time the branches were reloaded, causing you to
lose current branch selection.
  • Loading branch information...
1 parent a2217fe commit b255fb39d89a27179498a590855d182999e12ffe @pieter committed Sep 28, 2008
Showing with 9 additions and 4 deletions.
  1. +9 −4 PBGitRepository.m
View
@@ -131,6 +131,7 @@ - (BOOL)readFromFileWrapper:(NSFileWrapper *)fileWrapper ofType:(NSString *)type
- (void) setup
{
+ self.branches = [NSMutableArray array];
[self reloadRefs];
revisionList = [[PBGitRevList alloc] initWithRepository:self];
}
@@ -197,11 +198,15 @@ - (void) addRef: (PBGitRef *) ref fromParameters: (NSArray *) components
- (BOOL) reloadRefs
{
BOOL ret = NO;
- self.branches = [NSMutableArray array];
- NSString* output = [PBEasyPipe outputForCommand:gitPath withArgs:[NSArray arrayWithObjects:@"for-each-ref", @"--format=%(refname) %(objecttype) %(objectname) %(*objectname)", @"refs", nil] inDir: self.fileURL.path];
- NSArray* lines = [output componentsSeparatedByString:@"\n"];
+
refs = [NSMutableDictionary dictionary];
+ NSString* output = [PBEasyPipe outputForCommand:gitPath
+ withArgs:[NSArray arrayWithObjects:@"for-each-ref", @"--format=%(refname) %(objecttype) %(objectname)"
+ " %(*objectname)", @"refs", nil]
+ inDir: self.fileURL.path];
+ NSArray* lines = [output componentsSeparatedByString:@"\n"];
+
for (NSString* line in lines) {
NSArray* components = [line componentsSeparatedByString:@" "];
@@ -214,8 +219,8 @@ - (BOOL) reloadRefs
// Also add this ref to the refs list
[self addRef:newRef fromParameters:components];
-
}
+
self.refs = refs;
return ret;
}

0 comments on commit b255fb3

Please sign in to comment.