File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -87,7 +87,11 @@ - (nullable instancetype)initWithReference:(GTReference *)ref {
8787}
8888
8989- (NSString *)name {
90- return self.reference .name ;
90+ const char *charName;
91+ int gitError = git_branch_name (&charName, self.reference .git_reference );
92+ if (gitError != GIT_OK || charName == NULL ) return nil ;
93+
94+ return @(charName);
9195}
9296
9397- (NSString *)shortName {
Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ - (BOOL)mergeBranchIntoCurrentBranch:(GTBranch *)branch withError:(NSError **)er
159159 NSArray *parents = @[ localCommit, remoteCommit ];
160160
161161 // FIXME: This is stepping on the local tree
162- GTCommit *mergeCommit = [self createCommitWithTree: newTree message: message parents: parents updatingReferenceNamed: localBranch.name error: error];
162+ GTCommit *mergeCommit = [self createCommitWithTree: newTree message: message parents: parents updatingReferenceNamed: localBranch.reference .name error: error];
163163 if (!mergeCommit) {
164164 return NO ;
165165 }
Original file line number Diff line number Diff line change 3434 expect (error).to (beNil ());
3535});
3636
37+ describe (@" name" , ^{
38+ it (@" should use just the branch name for a local branch" , ^{
39+ expect (masterBranch.name ).to (equal (@" master" ));
40+ });
41+
42+ it (@" should include the remote name for a tracking branch" , ^{
43+ expect (trackingBranch.name ).to (equal (@" origin/master" ));
44+ });
45+ });
46+
3747describe (@" shortName" , ^{
3848 it (@" should use just the branch name for a local branch" , ^{
3949 expect (masterBranch.shortName ).to (equal (@" master" ));
Original file line number Diff line number Diff line change 268268 GTBranch *currentBranch = [repository currentBranchWithError: &error];
269269 expect (currentBranch).notTo (beNil ());
270270 expect (error).to (beNil ());
271- expect (currentBranch.name ).to (equal (@" refs/heads/ master" ));
271+ expect (currentBranch.name ).to (equal (@" master" ));
272272 });
273273});
274274
308308 expect (error).to (beNil ());
309309 expect (@(branches.count )).to (equal (@1 ));
310310 GTBranch *remoteBranch = branches[0 ];
311- expect (remoteBranch.name ).to (equal (@" refs/remotes/ origin/master" ));
311+ expect (remoteBranch.name ).to (equal (@" origin/master" ));
312312 });
313313});
314314
You can’t perform that action at this time.
0 commit comments