-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #463 from libgit2/look-up-ref
Look up ref
- Loading branch information
Showing
11 changed files
with
82 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// GTRepository+References.h | ||
// ObjectiveGitFramework | ||
// | ||
// Created by Josh Abernathy on 6/4/15. | ||
// Copyright (c) 2015 GitHub, Inc. All rights reserved. | ||
// | ||
|
||
#import "GTrepository.h" | ||
|
||
@class GTReference; | ||
|
||
@interface GTRepository (References) | ||
|
||
/// Look up a reference by name. | ||
/// | ||
/// name - The name of the reference to look up. Cannot be nil. | ||
/// error - The error if one occurs. May be NULL. | ||
/// | ||
/// Returns the reference or nil if look up failed. | ||
- (GTReference *)lookUpReferenceWithName:(NSString *)name error:(NSError **)error; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// GTRepository+References.m | ||
// ObjectiveGitFramework | ||
// | ||
// Created by Josh Abernathy on 6/4/15. | ||
// Copyright (c) 2015 GitHub, Inc. All rights reserved. | ||
// | ||
|
||
#import "GTRepository+References.h" | ||
#import "GTReference.h" | ||
#import "NSError+Git.h" | ||
|
||
#import "git2/errors.h" | ||
|
||
@implementation GTRepository (References) | ||
|
||
- (GTReference *)lookUpReferenceWithName:(NSString *)name error:(NSError **)error { | ||
NSParameterAssert(name != nil); | ||
|
||
git_reference *ref = NULL; | ||
int gitError = git_reference_lookup(&ref, self.git_repository, name.UTF8String); | ||
if (gitError != GIT_OK) { | ||
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to lookup reference %@.", name]; | ||
return nil; | ||
} | ||
|
||
return [[GTReference alloc] initWithGitReference:ref repository:self]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters