Skip to content

Commit 9e04117

Browse files
committed
Merge branch 'master' into phatblat/pr/swift1.2
# Conflicts: # ObjectiveGit/GTReference.h # ObjectiveGit/GTReference.m
2 parents d70d7f4 + d4e18a9 commit 9e04117

File tree

14 files changed

+92
-42
lines changed

14 files changed

+92
-42
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
url = https://github.com/openssl/openssl.git
77
[submodule "libssh2"]
88
path = External/libssh2
9-
url = git://git.libssh2.org/libssh2.git
9+
url = https://github.com/libssh2/libssh2.git
1010
[submodule "Carthage.checkout/Nimble"]
1111
path = Carthage/Checkouts/Nimble
1212
url = https://github.com/Quick/Nimble.git

ObjectiveGit/GTReference.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,8 @@ NS_ASSUME_NONNULL_BEGIN
6161
@property (nonatomic, readonly, strong) GTReflog *reflog;
6262

6363
/// Convenience initializers
64-
+ (instancetype)referenceByLookingUpReferencedNamed:(NSString *)refName inRepository:(GTRepository *)theRepo error:(NSError **)error;
65-
- (instancetype)initByLookingUpReferenceNamed:(NSString *)refName inRepository:(GTRepository *)theRepo error:(NSError **)error;
66-
67-
+ (instancetype)referenceByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError **)error;
68-
- (instancetype)initByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError **)error;
64+
+ (id)referenceByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError **)error;
65+
- (id)initByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError **)error;
6966

7067
/// Designated initializer.
7168
///

ObjectiveGit/GTReference.m

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#import "GTSignature.h"
3333
#import "NSError+Git.h"
3434
#import "NSString+Git.h"
35+
#import "GTRepository+References.h"
3536

3637
#import "git2/errors.h"
3738

@@ -69,29 +70,11 @@ - (BOOL)isRemote {
6970
return git_reference_is_remote(self.git_reference) != 0;
7071
}
7172

72-
+ (instancetype)referenceByLookingUpReferencedNamed:(NSString *)refName inRepository:(GTRepository *)theRepo error:(NSError **)error {
73-
return [[self alloc] initByLookingUpReferenceNamed:refName inRepository:theRepo error:error];
74-
}
75-
76-
+ (instancetype)referenceByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError **)error {
73+
+ (id)referenceByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError **)error {
7774
return [[self alloc] initByResolvingSymbolicReference:symbolicRef error:error];
7875
}
7976

80-
- (instancetype)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-
- (instancetype)initByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError **)error {
77+
- (id)initByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError **)error {
9578
NSParameterAssert(symbolicRef != nil);
9679

9780
git_reference *ref = NULL;
@@ -151,7 +134,7 @@ - (id)unresolvedTarget {
151134
NSString *refName = @(git_reference_symbolic_target(self.git_reference));
152135
if (refName == NULL) return nil;
153136

154-
return [self.class referenceByLookingUpReferencedNamed:refName inRepository:self.repository error:NULL];
137+
return [self.repository lookUpReferenceWithName:refName error:NULL];
155138
}
156139
return nil;
157140
}
@@ -221,7 +204,7 @@ - (GTOID *)OID {
221204
}
222205

223206
- (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];
225208
}
226209

227210
+ (NSError *)invalidReferenceError {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// GTRepository+References.h
3+
// ObjectiveGitFramework
4+
//
5+
// Created by Josh Abernathy on 6/4/15.
6+
// Copyright (c) 2015 GitHub, Inc. All rights reserved.
7+
//
8+
9+
#import "GTrepository.h"
10+
11+
@class GTReference;
12+
13+
@interface GTRepository (References)
14+
15+
/// Look up a reference by name.
16+
///
17+
/// name - The name of the reference to look up. Cannot be nil.
18+
/// error - The error if one occurs. May be NULL.
19+
///
20+
/// Returns the reference or nil if look up failed.
21+
- (GTReference *)lookUpReferenceWithName:(NSString *)name error:(NSError **)error;
22+
23+
@end
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// GTRepository+References.m
3+
// ObjectiveGitFramework
4+
//
5+
// Created by Josh Abernathy on 6/4/15.
6+
// Copyright (c) 2015 GitHub, Inc. All rights reserved.
7+
//
8+
9+
#import "GTRepository+References.h"
10+
#import "GTReference.h"
11+
#import "NSError+Git.h"
12+
13+
#import "git2/errors.h"
14+
15+
@implementation GTRepository (References)
16+
17+
- (GTReference *)lookUpReferenceWithName:(NSString *)name error:(NSError **)error {
18+
NSParameterAssert(name != nil);
19+
20+
git_reference *ref = NULL;
21+
int gitError = git_reference_lookup(&ref, self.git_repository, name.UTF8String);
22+
if (gitError != GIT_OK) {
23+
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to lookup reference %@.", name];
24+
return nil;
25+
}
26+
27+
return [[GTReference alloc] initWithGitReference:ref repository:self];
28+
}
29+
30+
@end

ObjectiveGit/GTRepository+RemoteOperations.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#import "GTSignature.h"
1818
#import "NSArray+StringArray.h"
1919
#import "NSError+Git.h"
20+
#import "GTRepository+References.h"
2021

2122
#import "git2/errors.h"
2223
#import "git2/remote.h"
@@ -120,7 +121,7 @@ int GTFetchHeadEntriesCallback(const char *ref_name, const char *remote_url, con
120121
GTRepository *repository = entriesPayload->repository;
121122
GTRemoteEnumerateFetchHeadEntryBlock enumerationBlock = entriesPayload->enumerationBlock;
122123

123-
GTReference *reference = [GTReference referenceByLookingUpReferencedNamed:@(ref_name) inRepository:repository error:NULL];
124+
GTReference *reference = [repository lookUpReferenceWithName:@(ref_name) error:NULL];
124125

125126
GTFetchHeadEntry *entry = [[GTFetchHeadEntry alloc] initWithReference:reference remoteURLString:@(remote_url) targetOID:[GTOID oidWithGitOid:oid] isMerge:(BOOL)is_merge];
126127

ObjectiveGit/GTRepository.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#import "NSArray+StringArray.h"
5252
#import "NSError+Git.h"
5353
#import "NSString+Git.h"
54+
#import "GTRepository+References.h"
5455

5556
#import "git2.h"
5657

@@ -401,7 +402,7 @@ - (NSArray *)branchesWithPrefix:(NSString *)prefix error:(NSError **)error {
401402
for (NSString *refName in references) {
402403
if (![refName hasPrefix:prefix]) continue;
403404

404-
GTReference *ref = [[GTReference alloc] initByLookingUpReferenceNamed:refName inRepository:self error:error];
405+
GTReference *ref = [self lookUpReferenceWithName:refName error:error];
405406
if (ref == nil) continue;
406407

407408
GTBranch *branch = [[GTBranch alloc] initWithReference:ref repository:self];
@@ -457,7 +458,9 @@ static int GTRepositoryForeachTagCallback(const char *name, git_oid *oid, void *
457458
GTTag *tag = (GTTag *)[info->myself lookUpObjectByGitOid:oid objectType:GTObjectTypeTag error:NULL];
458459

459460
BOOL stop = NO;
460-
info->block(tag, &stop);
461+
if (tag != nil) {
462+
info->block(tag, &stop);
463+
}
461464

462465
return stop ? GIT_EUSER : 0;
463466
}

ObjectiveGit/ObjectiveGit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ FOUNDATION_EXPORT const unsigned char ObjectiveGitVersionString[];
3737
#import <ObjectiveGit/GTRepository+Stashing.h>
3838
#import <ObjectiveGit/GTRepository+Committing.h>
3939
#import <ObjectiveGit/GTRepository+Status.h>
40+
#import <ObjectiveGit/GTRepository+References.h>
4041
#import <ObjectiveGit/GTRepository+RemoteOperations.h>
4142
#import <ObjectiveGit/GTRepository+Reset.h>
4243
#import <ObjectiveGit/GTEnumerator.h>

ObjectiveGitFramework.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@
129129
889923FB19FF5DD40092A9A6 /* git2 in Headers */ = {isa = PBXBuildFile; fileRef = 889923F919FF5DD40092A9A6 /* git2 */; settings = {ATTRIBUTES = (Public, ); }; };
130130
88A994BA16FCE7D400402C7B /* GTBranchSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 88A994B916FCE7D400402C7B /* GTBranchSpec.m */; };
131131
88A994CB16FCED1D00402C7B /* QuickSpec+GTFixtures.m in Sources */ = {isa = PBXBuildFile; fileRef = 88A994CA16FCED1D00402C7B /* QuickSpec+GTFixtures.m */; };
132+
88B2131C1B20E785005CF2C5 /* GTRepository+References.h in Headers */ = {isa = PBXBuildFile; fileRef = 88B2131A1B20E785005CF2C5 /* GTRepository+References.h */; settings = {ATTRIBUTES = (Public, ); }; };
133+
88B2131D1B20E785005CF2C5 /* GTRepository+References.h in Headers */ = {isa = PBXBuildFile; fileRef = 88B2131A1B20E785005CF2C5 /* GTRepository+References.h */; settings = {ATTRIBUTES = (Public, ); }; };
134+
88B2131E1B20E785005CF2C5 /* GTRepository+References.m in Sources */ = {isa = PBXBuildFile; fileRef = 88B2131B1B20E785005CF2C5 /* GTRepository+References.m */; };
135+
88B2131F1B20E785005CF2C5 /* GTRepository+References.m in Sources */ = {isa = PBXBuildFile; fileRef = 88B2131B1B20E785005CF2C5 /* GTRepository+References.m */; };
132136
88BC0E5018EF4F3600C7D0E6 /* GTRepository+Reset.h in Headers */ = {isa = PBXBuildFile; fileRef = 88BC0E4E18EF4F3600C7D0E6 /* GTRepository+Reset.h */; settings = {ATTRIBUTES = (Public, ); }; };
133137
88BC0E5218EF4F3600C7D0E6 /* GTRepository+Reset.m in Sources */ = {isa = PBXBuildFile; fileRef = 88BC0E4F18EF4F3600C7D0E6 /* GTRepository+Reset.m */; };
134138
88C0BC5917038CF3009E99AA /* GTConfigurationSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 88C0BC5817038CF3009E99AA /* GTConfigurationSpec.m */; };
@@ -471,6 +475,8 @@
471475
88A994B916FCE7D400402C7B /* GTBranchSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTBranchSpec.m; sourceTree = "<group>"; };
472476
88A994C916FCED1D00402C7B /* QuickSpec+GTFixtures.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "QuickSpec+GTFixtures.h"; sourceTree = "<group>"; };
473477
88A994CA16FCED1D00402C7B /* QuickSpec+GTFixtures.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "QuickSpec+GTFixtures.m"; sourceTree = "<group>"; };
478+
88B2131A1B20E785005CF2C5 /* GTRepository+References.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GTRepository+References.h"; sourceTree = "<group>"; };
479+
88B2131B1B20E785005CF2C5 /* GTRepository+References.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GTRepository+References.m"; sourceTree = "<group>"; };
474480
88BC0E4E18EF4F3600C7D0E6 /* GTRepository+Reset.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GTRepository+Reset.h"; sourceTree = "<group>"; };
475481
88BC0E4F18EF4F3600C7D0E6 /* GTRepository+Reset.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GTRepository+Reset.m"; sourceTree = "<group>"; };
476482
88C0BC5817038CF3009E99AA /* GTConfigurationSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTConfigurationSpec.m; sourceTree = "<group>"; };
@@ -779,6 +785,8 @@
779785
88746CC317FA1C950005888A /* GTRepository+Committing.m */,
780786
4DFFB159183AA8D600D1565E /* GTRepository+RemoteOperations.h */,
781787
4DFFB15A183AA8D600D1565E /* GTRepository+RemoteOperations.m */,
788+
88B2131A1B20E785005CF2C5 /* GTRepository+References.h */,
789+
88B2131B1B20E785005CF2C5 /* GTRepository+References.m */,
782790
BDD8AE6D13131B8800CB5D40 /* GTEnumerator.h */,
783791
BDD8AE6E13131B8800CB5D40 /* GTEnumerator.m */,
784792
BD6C22A71314625800992935 /* GTObject.h */,
@@ -964,6 +972,7 @@
964972
6EEB51A1199D62B9001D72C0 /* GTFetchHeadEntry.h in Headers */,
965973
BD441E08131ED0C300187010 /* GTReference.h in Headers */,
966974
88F6D9D91320451F00CC0BA8 /* ObjectiveGit.h in Headers */,
975+
88B2131C1B20E785005CF2C5 /* GTRepository+References.h in Headers */,
967976
88F6D9FA1320467100CC0BA8 /* GTCommit.h in Headers */,
968977
88F6D9FB1320467500CC0BA8 /* GTObject.h in Headers */,
969978
AA046112134F4D2000DF526B /* GTOdbObject.h in Headers */,
@@ -1015,6 +1024,7 @@
10151024
D01B6F1519F82F7B00D411BC /* NSData+Git.h in Headers */,
10161025
D01B6F6119F82FA600D411BC /* GTFilterSource.h in Headers */,
10171026
D0E0171519F9AD820019930C /* ObjectiveGit.h in Headers */,
1027+
88B2131D1B20E785005CF2C5 /* GTRepository+References.h in Headers */,
10181028
D01B6F4919F82F8700D411BC /* GTOdbObject.h in Headers */,
10191029
D01B6F3919F82F8700D411BC /* GTTreeEntry.h in Headers */,
10201030
D01B6F5B19F82FA600D411BC /* GTSubmodule.h in Headers */,
@@ -1318,6 +1328,7 @@
13181328
3011D8731668E78500CE3409 /* GTDiffHunk.m in Sources */,
13191329
3011D8791668F29600CE3409 /* GTDiffDelta.m in Sources */,
13201330
6EEB51A2199D62B9001D72C0 /* GTFetchHeadEntry.m in Sources */,
1331+
88B2131E1B20E785005CF2C5 /* GTRepository+References.m in Sources */,
13211332
30FDC08116835A8100654BF0 /* GTDiffLine.m in Sources */,
13221333
886E622C18AEBF75000611A0 /* GTFilterSource.m in Sources */,
13231334
DD3D9513182A81E1004AF532 /* GTBlame.m in Sources */,
@@ -1375,6 +1386,7 @@
13751386
D01B6F1A19F82F7B00D411BC /* NSString+Git.m in Sources */,
13761387
D01B6F2619F82F8700D411BC /* GTStatusDelta.m in Sources */,
13771388
D01B6F2019F82F8700D411BC /* GTRepository.m in Sources */,
1389+
88B2131F1B20E785005CF2C5 /* GTRepository+References.m in Sources */,
13781390
D01B6F7019F82FB300D411BC /* GTDiffHunk.m in Sources */,
13791391
D01B6F4819F82F8700D411BC /* GTObjectDatabase.m in Sources */,
13801392
D01B6F2C19F82F8700D411BC /* GTRepository+RemoteOperations.m in Sources */,

0 commit comments

Comments
 (0)