Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Select the current HEAD if running gitx without arguments

  • Loading branch information...
commit 3d42a4e942d244076596650d06128e8f94d4e858 1 parent 0617f11
@pieter authored
Showing with 13 additions and 5 deletions.
  1. +13 −5 PBGitRepository.m
View
18 PBGitRepository.m
@@ -183,14 +183,26 @@ - (void) readRefs
self.refs = newRefs;
}
+- (PBGitRevSpecifier*) headRef
+{
+ NSString* branch = [self parseSymbolicReference: @"HEAD"];
+ if (branch && [branch hasPrefix:@"refs/heads/"])
+ return [[PBGitRevSpecifier alloc] initWithRef:[PBGitRef refFromString:branch]];
+ return nil;
+}
+
// Returns either this object, or an existing, equal object
- (PBGitRevSpecifier*) addBranch: (PBGitRevSpecifier*) rev
{
+ if ([[rev parameters] count] == 0)
+ rev = [self headRef];
+
// First check if the branch doesn't exist already
for (PBGitRevSpecifier* r in branches)
if ([rev isEqualTo: r])
return r;
+ NSLog(@"Adding new branch");
[branches addObject: rev];
return rev;
}
@@ -209,11 +221,7 @@ - (void) selectBranch: (PBGitRevSpecifier*) rev
- (void) readCurrentBranch
{
- NSString* branch = [self parseSymbolicReference: @"HEAD"];
- if (branch && [branch hasPrefix:@"refs/heads/"]) {
- PBGitRevSpecifier* currentRev = [[PBGitRevSpecifier alloc] initWithRef:[PBGitRef refFromString:branch]];
- [self selectBranch: [self addBranch:currentRev]];
- }
+ [self selectBranch: [self addBranch: [self headRef]]];
}
Please sign in to comment.
Something went wrong with that request. Please try again.