|
32 | 32 | #import "GTSignature.h" |
33 | 33 | #import "NSError+Git.h" |
34 | 34 | #import "NSString+Git.h" |
| 35 | +#import "GTRepository+References.h" |
35 | 36 |
|
36 | 37 | #import "git2/errors.h" |
37 | 38 |
|
@@ -69,28 +70,10 @@ - (BOOL)isRemote { |
69 | 70 | return git_reference_is_remote(self.git_reference) != 0; |
70 | 71 | } |
71 | 72 |
|
72 | | -+ (id)referenceByLookingUpReferencedNamed:(NSString *)refName inRepository:(GTRepository *)theRepo error:(NSError **)error { |
73 | | - return [[self alloc] initByLookingUpReferenceNamed:refName inRepository:theRepo error:error]; |
74 | | -} |
75 | | - |
76 | 73 | + (id)referenceByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError **)error { |
77 | 74 | return [[self alloc] initByResolvingSymbolicReference:symbolicRef error:error]; |
78 | 75 | } |
79 | 76 |
|
80 | | -- (id)initByLookingUpReferenceNamed:(NSString *)refName inRepository:(GTRepository *)repo error:(NSError **)error { |
81 | | - NSParameterAssert(refName != nil); |
82 | | - NSParameterAssert(repo != nil); |
83 | | - |
84 | | - git_reference *ref = NULL; |
85 | | - int gitError = git_reference_lookup(&ref, repo.git_repository, refName.UTF8String); |
86 | | - if (gitError != GIT_OK) { |
87 | | - if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to lookup reference %@.", refName]; |
88 | | - return nil; |
89 | | - } |
90 | | - |
91 | | - return [self initWithGitReference:ref repository:repo]; |
92 | | -} |
93 | | - |
94 | 77 | - (id)initByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError **)error { |
95 | 78 | NSParameterAssert(symbolicRef != nil); |
96 | 79 |
|
@@ -151,7 +134,7 @@ - (id)unresolvedTarget { |
151 | 134 | NSString *refName = @(git_reference_symbolic_target(self.git_reference)); |
152 | 135 | if (refName == NULL) return nil; |
153 | 136 |
|
154 | | - return [self.class referenceByLookingUpReferencedNamed:refName inRepository:self.repository error:NULL]; |
| 137 | + return [self.repository lookUpReferenceWithName:refName error:NULL]; |
155 | 138 | } |
156 | 139 | return nil; |
157 | 140 | } |
@@ -221,7 +204,7 @@ - (GTOID *)OID { |
221 | 204 | } |
222 | 205 |
|
223 | 206 | - (GTReference *)reloadedReferenceWithError:(NSError **)error { |
224 | | - return [[self.class alloc] initByLookingUpReferenceNamed:self.name inRepository:self.repository error:error]; |
| 207 | + return [self.repository lookUpReferenceWithName:self.name error:error]; |
225 | 208 | } |
226 | 209 |
|
227 | 210 | + (NSError *)invalidReferenceError { |
|
0 commit comments