10000 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
Changes from 1 commit
Commits
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 remote name.
  • Loading branch information
tiennou committed Nov 26, 2017
commit b16d6c4296d3ca4285e7cf0d81e11c3a878c975f
14 changes: 5 additions & 9 deletions ObjectiveGit/GTBranch.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#import "GTRemote.h"
#import "GTRepository.h"
#import "NSError+Git.h"
#import "NSData+Git.h"

#import "git2/branch.h"
#import "git2/errors.h"
Expand Down Expand Up @@ -110,17 +111,12 @@ - (GTOID *)OID {
}

- (NSString *)remoteName {
if (self.branchType == GTBranchTypeLocal) return nil;

const char *name;
int gitError = git_branch_name(&name, self.reference.git_reference);
git_buf remote_name = GIT_BUF_INIT_CONST(0, NULL);
int gitError = git_branch_remote_name(&remote_name, self.repository.git_repository, self.reference.name.UTF8String);
if (gitError != GIT_OK) return nil;

// Find out where the remote name ends.
const char *end = strchr(name, '/');
if (end == NULL || end == name) return nil;

return [[NSString alloc] initWithBytes:name length:end - name encoding:NSUTF8StringEncoding];
NSData *data = [NSData git_dataWithBuffer:&remote_name];
return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
}

- (GTCommit *)targetCommitWithError:(NSError **)error {
Expand Down
0