|
32 | 32 | @interface PBGitRepository()
|
33 | 33 | @end
|
34 | 34 |
|
| 35 | +dispatch_queue_t PBGetWorkQueue() { |
| 36 | +#if 1 |
| 37 | + static dispatch_queue_t work_queue; |
| 38 | + static dispatch_once_t onceToken; |
| 39 | + dispatch_once(&onceToken, ^{ |
| 40 | + work_queue = dispatch_queue_create("PBWorkQueue", 0); |
| 41 | + }); |
| 42 | + return work_queue; |
| 43 | +#else |
| 44 | + return dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0); |
| 45 | +#endif |
| 46 | +} |
35 | 47 |
|
36 | 48 |
|
37 | 49 | @implementation PBGitRepository
|
@@ -250,11 +262,13 @@ - (NSString*)gitIgnoreFilename
|
250 | 262 |
|
251 | 263 | - (BOOL)isBareRepository
|
252 | 264 | {
|
253 |
| - if([self workingDirectory]) { |
254 |
| - return [PBGitRepository isBareRepository:[self workingDirectory]]; |
255 |
| - } else { |
256 |
| - return true; |
| 265 | + if(!didCheckBareRepository) { |
| 266 | + if([self workingDirectory]) |
| 267 | + bareRepository = [PBGitRepository isBareRepository:[self workingDirectory]]; |
| 268 | + else |
| 269 | + bareRepository = YES; |
257 | 270 | }
|
| 271 | + return bareRepository; |
258 | 272 | }
|
259 | 273 |
|
260 | 274 | // Overridden to create our custom window controller
|
@@ -358,11 +372,16 @@ - (void) reloadRefs
|
358 | 372 |
|
359 | 373 | PBGitRef *newRef = [PBGitRef refFromString:[components objectAtIndex:0]];
|
360 | 374 | PBGitRevSpecifier *revSpec = [[PBGitRevSpecifier alloc] initWithRef:newRef];
|
361 |
| - |
362 |
| - [revSpec setHelpText:[self helpTextForRef:newRef]]; |
363 | 375 | [self addBranch:revSpec];
|
364 | 376 | [self addRef:newRef fromParameters:components];
|
365 | 377 | [oldBranches removeObject:revSpec];
|
| 378 | + |
| 379 | + dispatch_async(PBGetWorkQueue(), ^{ |
| 380 | + NSString* helpText = [self helpTextForRef:newRef]; |
| 381 | + dispatch_async(dispatch_get_main_queue(), ^{ |
| 382 | + [revSpec setHelpText:helpText]; |
| 383 | + }); |
| 384 | + }); |
366 | 385 | }
|
367 | 386 |
|
368 | 387 | for (PBGitRevSpecifier *branch in oldBranches)
|
@@ -628,12 +647,14 @@ - (void) readCurrentBranch
|
628 | 647 |
|
629 | 648 | - (NSString *) workingDirectory
|
630 | 649 | {
|
631 |
| - if ([self.fileURL.path hasSuffix:@"/.git"]) |
632 |
| - return [self.fileURL.path substringToIndex:[self.fileURL.path length] - 5]; |
633 |
| - else if ([[self outputForCommand:@"rev-parse --is-inside-work-tree"] isEqualToString:@"true"]) |
634 |
| - return [PBGitBinary path]; |
| 650 | + if(!workingDirectory) { |
| 651 | + if ([self.fileURL.path hasSuffix:@"/.git"]) |
| 652 | + workingDirectory = [[self.fileURL.path substringToIndex:[self.fileURL.path length] - 5] retain]; |
| 653 | + else if ([[self outputForCommand:@"rev-parse --is-inside-work-tree"] isEqualToString:@"true"]) |
| 654 | + workingDirectory = [PBGitBinary path]; |
| 655 | + } |
635 | 656 |
|
636 |
| - return nil; |
| 657 | + return workingDirectory; |
637 | 658 | }
|
638 | 659 |
|
639 | 660 | #pragma mark Remotes
|
|
0 commit comments