8000 Tweaks by tiennou · Pull Request #587 · libgit2/objective-git · GitHub
[go: up one dir, main page]

Skip to content

Tweaks #587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Nov 26, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
8000
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use libgit2 function to get the branch name.
  • Loading branch information
tiennou committed Nov 26, 2017
commit 8a67e0826d4f57b5dc7585d14f610a8c0bb84473
6 changes: 5 additions & 1 deletion ObjectiveGit/GTBranch.m
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ - (instancetype)initWithReference:(GTReference *)ref {
}

- (NSString *)name {
return self.reference.name;
const char *charName;
int gitError = git_branch_name(&charName, self.reference.git_reference);
if (gitError != GIT_OK || charName == NULL) return nil;

return @(charName);
}

- (NSString *)shortName {
Expand Down
2 changes: 1 addition & 1 deletion ObjectiveGit/GTRepository+Merging.m
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ - (BOOL)mergeBranchIntoCurrentBranch:(GTBranch *)branch withError:(NSError **)er
NSArray *parents = @[ localCommit, remoteCommit ];

// FIXME: This is stepping on the local tree
GTCommit *mergeCommit = [self createCommitWithTree:newTree message:message parents:parents updatingReferenceNamed:localBranch.name error:error];
GTCommit *mergeCommit = [self createCommitWithTree:newTree message:message parents:parents updatingReferenceNamed:localBranch.reference.name error:error];
if (!mergeCommit) {
return NO;
}
Expand Down
10 changes: 10 additions & 0 deletions ObjectiveGitTests/GTBranchSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@
expect(error).to(beNil());
});

describe(@"name", ^{
it(@"should use just the branch name for a local branch", ^{
expect(masterBranch.name).to(equal(@"master"));
});

it(@"should include the remote name for a tracking branch", ^{
expect(trackingBranch.name).to(equal(@"origin/master"));
});
});

describe(@"shortName", ^{
it(@"should use just the branch name for a local branch", ^{
expect(masterBranch.shortName).to(equal(@"master"));
Expand Down
4 changes: 2 additions & 2 deletions ObjectiveGitTests/GTRepositorySpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
GTBranch *currentBranch = [repository currentBranchWithError:&error];
expect(currentBranch).notTo(beNil());
expect(error).to(beNil());
expect(currentBranch.name).to(equal(@"refs/heads/master"));
expect(currentBranch.name).to(equal(@"master"));
});
});

Expand Down Expand Up @@ -332,7 +332,7 @@
expect(error).to(beNil());
expect(@(branches.count)).to(equal(@1));
GTBranch *remoteBranch = branches[0];
expect(remoteBranch.name).to(equal(@"refs/remotes/origin/master"));
expect(remoteBranch.name).to(equal(@"origin/master"));
});
});

Expand Down
0