From b4d2b0d9bd06ca0d224d2075a57426f90b7b2b62 Mon Sep 17 00:00:00 2001 From: German Laullon Date: Wed, 5 Jan 2011 23:08:52 -0800 Subject: [PATCH 1/4] check bug --- PBGitSidebarController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PBGitSidebarController.m b/PBGitSidebarController.m index 301bf16..9f33709 100644 --- a/PBGitSidebarController.m +++ b/PBGitSidebarController.m @@ -223,8 +223,8 @@ - (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(PBSourceViewCell *)cell forTableColumn:(NSTableColumn *)tableColumn item:(PBSourceViewItem *)item { + cell.isCheckedOut = [item.revSpecifier isEqual:[repository headRef]]; if(item.revSpecifier!=NULL){ - cell.isCheckedOut = [item.revSpecifier isEqual:[repository headRef]]; cell.behind=[item.revSpecifier behind]; cell.ahead=[item.revSpecifier ahead]; }else{ From 526f246896e3d50fbc733b3a402fc39b6e2176dc Mon Sep 17 00:00:00 2001 From: German Laullon Date: Wed, 5 Jan 2011 23:37:16 -0800 Subject: [PATCH 2/4] correct branch ahead/behind counters --- PBGitRepository.h | 2 +- PBGitRepository.m | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/PBGitRepository.h b/PBGitRepository.h index a16acc0..9c61a60 100644 --- a/PBGitRepository.h +++ b/PBGitRepository.h @@ -129,7 +129,7 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) { - (void)findInModeScriptCommand:(NSScriptCommand *)command; -(NSNumber *)countCommintsOf:(NSString *)branchs; -+(bool)isLocalBranch:(NSString *)name; ++(bool)isLocalBranch:(NSString *)branch branchNameInto:(NSString **)name; @property (assign) BOOL hasChanged; diff --git a/PBGitRepository.m b/PBGitRepository.m index edec8ec..db5e650 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -269,9 +269,10 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; PBGitRef *newRef = [PBGitRef refFromString:[components objectAtIndex:0]]; PBGitRevSpecifier *revSpec = [[PBGitRevSpecifier alloc] initWithRef:newRef]; - if([PBGitRepository isLocalBranch:[components objectAtIndex:0]]){ - [revSpec setAhead:[self countCommintsOf:[NSString stringWithFormat:@"origin..%@",[components objectAtIndex:0]]]]; - [revSpec setBehind:[self countCommintsOf:[NSString stringWithFormat:@"%@..origin",[components objectAtIndex:0]]]]; + NSString *bName; + if([PBGitRepository isLocalBranch:[components objectAtIndex:0] branchNameInto:&bName]){ + [revSpec setAhead:[self countCommintsOf:[NSString stringWithFormat:@"origin/%@..%@",bName,bName]]]; + [revSpec setBehind:[self countCommintsOf:[NSString stringWithFormat:@"%@..origin/%@",bName,bName]]]; } [self addBranch:revSpec]; [self addRef:newRef fromParameters:components]; @@ -288,14 +289,19 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; [[[self windowController] window] setTitle:[self displayName]]; } -+(bool)isLocalBranch:(NSString *)name ++(bool)isLocalBranch:(NSString *)branch branchNameInto:(NSString **)name { - NSScanner *scanner=[NSScanner scannerWithString:name]; - return [scanner scanString:@"refs/heads/" intoString:NULL]; + NSScanner *scanner=[NSScanner scannerWithString:branch]; + bool is=[scanner scanString:@"refs/heads/" intoString:NULL]; + if(is && (name)){ + *name=[branch substringFromIndex:[scanner scanLocation]]; + } + return is; } -(NSNumber *)countCommintsOf:(NSString *)branchs { + NSLog(@"branchs:'%@'",branchs); NSArray *args = [NSArray arrayWithObjects:@"rev-list", branchs, nil]; NSString *o = [self outputForArguments:args]; if ([o length]==0) { From 8249c9605d99509debf0f40013bccf7750373dad Mon Sep 17 00:00:00 2001 From: German Laullon Date: Thu, 6 Jan 2011 00:03:21 -0800 Subject: [PATCH 3/4] error control on branch counters --- PBGitRepository.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PBGitRepository.m b/PBGitRepository.m index db5e650..01992c8 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -303,8 +303,9 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; { NSLog(@"branchs:'%@'",branchs); NSArray *args = [NSArray arrayWithObjects:@"rev-list", branchs, nil]; - NSString *o = [self outputForArguments:args]; - if ([o length]==0) { + int ret; + NSString *o = [self outputForArguments:args retValue:&ret]; + if ((ret!=0) || ([o length]==0)) { return NULL; } NSArray *commits = [o componentsSeparatedByString:@"\n"]; From 0253054fe5f6f13f940bf01951c6a77d02862414 Mon Sep 17 00:00:00 2001 From: German Laullon Date: Thu, 6 Jan 2011 00:03:44 -0800 Subject: [PATCH 4/4] avoid unnecessary reloads --- PBGitHistoryList.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PBGitHistoryList.m b/PBGitHistoryList.m index 0a4433f..0ab1324 100644 --- a/PBGitHistoryList.m +++ b/PBGitHistoryList.m @@ -287,7 +287,7 @@ - (BOOL) haveRefsBeenModified { - [repository reloadRefs]; + //[repository reloadRefs]; NSMutableSet *currentRefSHAs = [NSMutableSet setWithArray:[repository.refs allKeys]]; [currentRefSHAs minusSet:lastRefSHAs];