Skip to content

Commit 9057911

Browse files
committed
Merge branch 'refs/heads/branch-status'
2 parents bee812f + 0253054 commit 9057911

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

PBGitHistoryList.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ - (BOOL) selectedBranchNeedsNewGraph:(PBGitRevSpecifier *)rev
287287

288288
- (BOOL) haveRefsBeenModified
289289
{
290-
[repository reloadRefs];
290+
//[repository reloadRefs];
291291

292292
NSMutableSet *currentRefSHAs = [NSMutableSet setWithArray:[repository.refs allKeys]];
293293
[currentRefSHAs minusSet:lastRefSHAs];

PBGitRepository.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) {
129129
- (void)findInModeScriptCommand:(NSScriptCommand *)command;
130130

131131
-(NSNumber *)countCommintsOf:(NSString *)branchs;
132-
+(bool)isLocalBranch:(NSString *)name;
132+
+(bool)isLocalBranch:(NSString *)branch branchNameInto:(NSString **)name;
133133

134134

135135
@property (assign) BOOL hasChanged;

PBGitRepository.m

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,10 @@ - (void) reloadRefs
269269
PBGitRef *newRef = [PBGitRef refFromString:[components objectAtIndex:0]];
270270
PBGitRevSpecifier *revSpec = [[PBGitRevSpecifier alloc] initWithRef:newRef];
271271

272-
if([PBGitRepository isLocalBranch:[components objectAtIndex:0]]){
273-
[revSpec setAhead:[self countCommintsOf:[NSString stringWithFormat:@"origin..%@",[components objectAtIndex:0]]]];
274-
[revSpec setBehind:[self countCommintsOf:[NSString stringWithFormat:@"%@..origin",[components objectAtIndex:0]]]];
272+
NSString *bName;
273+
if([PBGitRepository isLocalBranch:[components objectAtIndex:0] branchNameInto:&bName]){
274+
[revSpec setAhead:[self countCommintsOf:[NSString stringWithFormat:@"origin/%@..%@",bName,bName]]];
275+
[revSpec setBehind:[self countCommintsOf:[NSString stringWithFormat:@"%@..origin/%@",bName,bName]]];
275276
}
276277
[self addBranch:revSpec];
277278
[self addRef:newRef fromParameters:components];
@@ -288,17 +289,23 @@ - (void) reloadRefs
288289
[[[self windowController] window] setTitle:[self displayName]];
289290
}
290291

291-
+(bool)isLocalBranch:(NSString *)name
292+
+(bool)isLocalBranch:(NSString *)branch branchNameInto:(NSString **)name
292293
{
293-
NSScanner *scanner=[NSScanner scannerWithString:name];
294-
return [scanner scanString:@"refs/heads/" intoString:NULL];
294+
NSScanner *scanner=[NSScanner scannerWithString:branch];
295+
bool is=[scanner scanString:@"refs/heads/" intoString:NULL];
296+
if(is && (name)){
297+
*name=[branch substringFromIndex:[scanner scanLocation]];
298+
}
299+
return is;
295300
}
296301

297302
-(NSNumber *)countCommintsOf:(NSString *)branchs
298303
{
304+
NSLog(@"branchs:'%@'",branchs);
299305
NSArray *args = [NSArray arrayWithObjects:@"rev-list", branchs, nil];
300-
NSString *o = [self outputForArguments:args];
301-
if ([o length]==0) {
306+
int ret;
307+
NSString *o = [self outputForArguments:args retValue:&ret];
308+
if ((ret!=0) || ([o length]==0)) {
302309
return NULL;
303310
}
304311
NSArray *commits = [o componentsSeparatedByString:@"\n"];

PBGitSidebarController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ - (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item
223223

224224
- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(PBSourceViewCell *)cell forTableColumn:(NSTableColumn *)tableColumn item:(PBSourceViewItem *)item
225225
{
226+
cell.isCheckedOut = [item.revSpecifier isEqual:[repository headRef]];
226227
if(item.revSpecifier!=NULL){
227-
cell.isCheckedOut = [item.revSpecifier isEqual:[repository headRef]];
228228
cell.behind=[item.revSpecifier behind];
229229
cell.ahead=[item.revSpecifier ahead];
230230
}else{

0 commit comments

Comments
 (0)