Skip to content

Commit 6f00cf0

Browse files
committed
Merge branch 'master' into conflict_marked_file
2 parents 831722b + c294035 commit 6f00cf0

File tree

98 files changed

+949
-489
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+949
-489
lines changed

.travis.yml

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
1-
osx_image: xcode8
1+
#
2+
# .travis.yml
3+
# Objective-Git
4+
#
5+
# https://docs.travis-ci.com/user/reference/osx/
6+
# https://docs.travis-ci.com/user/build-stages/matrix-expansion/
7+
#
8+
---
9+
os: osx
10+
osx_image: xcode9.3
211
language: objective-c
12+
313
matrix:
414
fast_finish: true
515
include:
6-
- osx_image: xcode8
16+
- osx_image: xcode9.3
717
env:
818
- SCHEME="ObjectiveGit Mac"
9-
- osx_image: xcode8
19+
- osx_image: xcode9.3
1020
env:
1121
- SCHEME="ObjectiveGit iOS"
22+
1223
before_install:
1324
- gem install xcpretty
1425
- gem install xcpretty-travis-formatter
1526
install: script/bootstrap
1627
script: script/cibuild
28+
1729
notifications:
1830
email: false

Cartfile.private

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
github "jspahrsummers/xcconfigs" >= 0.7.1
2-
github "Quick/Quick" ~> 0.9.2
3-
github "Quick/Nimble" ~> 4.0
4-
github "ZipArchive/ZipArchive" ~> 1.1
1+
github "jspahrsummers/xcconfigs" "master"
2+
github "Quick/Quick" ~> 1.2.0
3+
github "Quick/Nimble" ~> 7.1.0
4+
github "ZipArchive/ZipArchive" ~> 2.1.2

Cartfile.resolved

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
github "Quick/Nimble" "v4.1.0"
2-
github "Quick/Quick" "v0.9.3"
3-
github "ZipArchive/ZipArchive" "v1.6.2"
4-
github "jspahrsummers/xcconfigs" "0.9"
1+
github "Quick/Nimble" "v7.1.0"
2+
github "Quick/Quick" "v1.2.0"
3+
github "ZipArchive/ZipArchive" "v2.1.2"
4+
github "jspahrsummers/xcconfigs" "bb795558a76e5daf3688500055bbcfe243bffa8d"

Carthage/Checkouts/Nimble

Submodule Nimble updated 192 files

Carthage/Checkouts/Quick

Submodule Quick updated 161 files

Carthage/Checkouts/ZipArchive

Submodule ZipArchive updated 100 files

Carthage/Checkouts/xcconfigs

External/libcrypto.a

-1
This file was deleted.

External/libextobjc/extobjc/EXTScope.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
_Pragma("clang diagnostic pop")
8989

9090
/*** implementation details follow ***/
91-
typedef void (^gt_ext_cleanupBlock_t)();
91+
typedef void (^gt_ext_cleanupBlock_t)(void);
9292

9393
void gt_ext_executeCleanupBlock (__strong gt_ext_cleanupBlock_t *block);
9494

External/libgit2

Submodule libgit2 updated 752 files

External/libssh2

Submodule libssh2 updated 198 files

External/libssl.a

-1
This file was deleted.

External/openssl

Submodule openssl updated 1789 files

ObjectiveGit.modulemap

+2
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ framework module ObjectiveGit {
5757
header "git2/sys/hashsig.h"
5858
header "git2/sys/index.h"
5959
header "git2/sys/mempack.h"
60+
header "git2/sys/merge.h"
6061
header "git2/sys/odb_backend.h"
6162
header "git2/sys/refdb_backend.h"
6263
header "git2/sys/reflog.h"
6364
header "git2/sys/refs.h"
6465
header "git2/sys/repository.h"
6566
header "git2/sys/transport.h"
67+
header "git2/sys/time.h"
6668
header "git2/cred_helpers.h"
6769
header "git2/sys/openssl.h"
6870
header "git2/sys/stream.h"

ObjectiveGit/GTBlob.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ NS_ASSUME_NONNULL_BEGIN
104104
- (git_blob *)git_blob __attribute__((objc_returns_inner_pointer));
105105

106106
- (git_off_t)size;
107-
- (NSString *)content;
108-
- (NSData * _Nullable)data;
107+
- (NSString * _Nullable)content;
108+
- (NSData *)data;
109109

110110
/// Attempts to apply the filter list for `path` to the blob.
111111
///

ObjectiveGit/GTBlob.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
@implementation GTBlob
4141

4242
- (NSString *)description {
43-
return [NSString stringWithFormat:@"<%@: %p> size: %zi, content: %@, data = %@", NSStringFromClass([self class]), self, [self size], [self content], [self data]];
43+
return [NSString stringWithFormat:@"<%@: %p> size: %lli, content: %@, data = %@", NSStringFromClass([self class]), self, [self size], [self content], [self data]];
4444
}
4545

4646

ObjectiveGit/GTBranch.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ NS_ASSUME_NONNULL_BEGIN
5050
@property (nonatomic, readonly) GTBranchType branchType;
5151
@property (nonatomic, readonly, strong) GTRepository *repository;
5252
@property (nonatomic, readonly, strong) GTReference *reference;
53+
@property (nonatomic, readonly, getter=isHEAD) BOOL HEAD;
5354

5455
+ (NSString *)localNamePrefix;
5556
+ (NSString *)remoteNamePrefix;
@@ -59,18 +60,16 @@ NS_ASSUME_NONNULL_BEGIN
5960
/// Designated initializer.
6061
///
6162
/// ref - The branch reference to wrap. Must not be nil.
62-
/// repo - The repository containing the branch. Must not be nil.
6363
///
6464
/// Returns the initialized receiver.
65-
- (instancetype _Nullable)initWithReference:(GTReference *)ref repository:(GTRepository *)repo NS_DESIGNATED_INITIALIZER;
65+
- (instancetype _Nullable)initWithReference:(GTReference *)ref NS_DESIGNATED_INITIALIZER;
6666

6767
/// Convenience class initializer.
6868
///
6969
/// ref - The branch reference to wrap. Must not be nil.
70-
/// repo - The repository containing the branch. Must not be nil.
7170
///
7271
/// Returns an initialized instance.
73-
+ (instancetype _Nullable)branchWithReference:(GTReference *)ref repository:(GTRepository *)repo;
72+
+ (instancetype _Nullable)branchWithReference:(GTReference *)ref;
7473

7574
/// Get the target commit for this branch
7675
///
@@ -79,6 +78,9 @@ NS_ASSUME_NONNULL_BEGIN
7978
/// returns a GTCommit object or nil if an error occurred
8079
- (GTCommit * _Nullable)targetCommitWithError:(NSError **)error;
8180

81+
/// Renames the branch. Setting `force` to YES to delete another branch with the same name.
82+
- (BOOL)rename:(NSString *)name force:(BOOL)force error:(NSError **)error;
83+
8284
/// Count all commits in this branch
8385
///
8486
/// error(out) - will be filled if an error occurs

ObjectiveGit/GTBranch.m

+68-27
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#import "GTRemote.h"
3333
#import "GTRepository.h"
3434
#import "NSError+Git.h"
35+
#import "NSData+Git.h"
3536

3637
#import "git2/branch.h"
3738
#import "git2/errors.h"
@@ -65,30 +66,32 @@ + (NSString *)remoteNamePrefix {
6566
return @"refs/remotes/";
6667
}
6768

68-
+ (instancetype)branchWithReference:(GTReference *)ref repository:(GTRepository *)repo {
69-
return [[self alloc] initWithReference:ref repository:repo];
69+
+ (instancetype)branchWithReference:(GTReference *)ref {
70+
return [[self alloc] initWithReference:ref];
7071
}
7172

7273
- (instancetype)init {
7374
NSAssert(NO, @"Call to an unavailable initializer.");
7475
return nil;
7576
}
7677

77-
- (instancetype)initWithReference:(GTReference *)ref repository:(GTRepository *)repo {
78+
- (instancetype)initWithReference:(GTReference *)ref {
7879
NSParameterAssert(ref != nil);
79-
NSParameterAssert(repo != nil);
8080

8181
self = [super init];
8282
if (self == nil) return nil;
8383

84-
_repository = repo;
8584
_reference = ref;
8685

8786
return self;
8887
}
8988

9089
- (NSString *)name {
91-
return self.reference.name;
90+
const char *charName;
91+
int gitError = git_branch_name(&charName, self.reference.git_reference);
92+
if (gitError != GIT_OK || charName == NULL) return nil;
93+
94+
return @(charName);
9295
}
9396

9497
- (NSString *)shortName {
@@ -112,36 +115,39 @@ - (GTOID *)OID {
112115
}
113116

114117
- (NSString *)remoteName {
115-
if (self.branchType == GTBranchTypeLocal) return nil;
116-
117-
const char *name;
118-
int gitError = git_branch_name(&name, self.reference.git_reference);
118+
git_buf remote_name = GIT_BUF_INIT_CONST(0, NULL);
119+
int gitError = git_branch_remote_name(&remote_name, self.repository.git_repository, self.reference.name.UTF8String);
119120
if (gitError != GIT_OK) return nil;
120121

121-
// Find out where the remote name ends.
122-
const char *end = strchr(name, '/');
123-
if (end == NULL || end == name) return nil;
124-
125-
return [[NSString alloc] initWithBytes:name length:end - name encoding:NSUTF8StringEncoding];
122+
NSData *data = [NSData git_dataWithBuffer:&remote_name];
123+
return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
126124
}
127125

128126
- (GTCommit *)targetCommitWithError:(NSError **)error {
129-
if (self.OID == nil) {
127+
GTOID *oid = self.OID;
128+
if (oid == nil) {
130129
if (error != NULL) *error = GTReference.invalidReferenceError;
131130
return nil;
132131
}
133132

134-
return [self.repository lookUpObjectByOID:self.OID objectType:GTObjectTypeCommit error:error];
133+
return [self.repository lookUpObjectByOID:oid objectType:GTObjectTypeCommit error:error];
135134
}
136135

137136
- (NSUInteger)numberOfCommitsWithError:(NSError **)error {
138137
GTEnumerator *enumerator = [[GTEnumerator alloc] initWithRepository:self.repository error:error];
139138
if (enumerator == nil) return NSNotFound;
140139

141-
if (![enumerator pushSHA:self.OID.SHA error:error]) return NSNotFound;
140+
GTOID *oid = self.OID;
141+
if (oid == nil) return NSNotFound;
142+
143+
if (![enumerator pushSHA:oid.SHA error:error]) return NSNotFound;
142144
return [enumerator countRemainingObjects:error];
143145
}
144146

147+
- (GTRepository *)repository {
148+
return self.reference.repository;
149+
}
150+
145151
- (GTBranchType)branchType {
146152
if (self.reference.remote) {
147153
return GTBranchTypeRemote;
@@ -150,8 +156,14 @@ - (GTBranchType)branchType {
150156
}
151157
}
152158

159+
- (BOOL)isHEAD {
160+
return (git_branch_is_head(self.reference.git_reference) ? YES : NO);
161+
}
162+
153163
- (NSArray *)uniqueCommitsRelativeToBranch:(GTBranch *)otherBranch error:(NSError **)error {
154-
GTEnumerator *enumerator = [self.repository enumeratorForUniqueCommitsFromOID:self.OID relativeToOID:otherBranch.OID error:error];
164+
GTOID *oid = self.OID;
165+
GTOID *otherOID = otherBranch.OID;
166+
GTEnumerator *enumerator = [self.repository enumeratorForUniqueCommitsFromOID:oid relativeToOID:otherOID error:error];
155167
return [enumerator allObjectsWithError:error];
156168
}
157169

@@ -165,9 +177,29 @@ - (BOOL)deleteWithError:(NSError **)error {
165177
return YES;
166178
}
167179

180+
- (BOOL)rename:(NSString *)name force:(BOOL)force error:(NSError **)error {
181+
git_reference *git_ref;
182+
int gitError = git_branch_move(&git_ref, self.reference.git_reference, name.UTF8String, (force ? 1 : 0));
183+
if (gitError != GIT_OK) {
184+
if (error) *error = [NSError git_errorFor:gitError description:@"Rename branch failed"];
185+
return NO;
186+
}
187+
188+
GTReference *renamedRef = [[GTReference alloc] initWithGitReference:git_ref repository:self.repository];
189+
NSAssert(renamedRef, @"Unable to allocate renamed ref");
190+
_reference = renamedRef;
191+
192+
return YES;
193+
}
194+
168195
- (GTBranch *)trackingBranchWithError:(NSError **)error success:(BOOL *)success {
196+
BOOL underSuccess = NO;
197+
if (success == NULL) {
198+
success = &underSuccess;
199+
}
200+
169201
if (self.branchType == GTBranchTypeRemote) {
170-
if (success != NULL) *success = YES;
202+
*success = YES;
171203
return self;
172204
}
173205

@@ -176,25 +208,32 @@ - (GTBranch *)trackingBranchWithError:(NSError **)error success:(BOOL *)success
176208

177209
// GIT_ENOTFOUND means no tracking branch found.
178210
if (gitError == GIT_ENOTFOUND) {
179-
if (success != NULL) *success = YES;
211+
*success = YES;
180212
return nil;
181213
}
182214

183215
if (gitError != GIT_OK) {
184-
if (success != NULL) *success = NO;
216+
*success = NO;
185217
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to create reference to tracking branch from %@", self];
186218
return nil;
187219
}
188220

189221
if (trackingRef == NULL) {
190-
if (success != NULL) *success = NO;
222+
*success = NO;
191223
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Got a NULL remote ref for %@", self];
192224
return nil;
193225
}
194226

195-
if (success != NULL) *success = YES;
227+
GTReference *upsteamRef = [[GTReference alloc] initWithGitReference:trackingRef repository:self.repository];
228+
if (upsteamRef == nil) {
229+
*success = NO;
230+
if (error != NULL) *error = [NSError git_errorFor:GIT_ERROR description:@"Failed to allocate upstream ref"];
231+
return nil;
232+
}
233+
234+
*success = YES;
196235

197-
return [[self class] branchWithReference:[[GTReference alloc] initWithGitReference:trackingRef repository:self.repository] repository:self.repository];
236+
return [[self class] branchWithReference:upsteamRef];
198237
}
199238

200239
- (BOOL)updateTrackingBranch:(GTBranch *)trackingBranch error:(NSError **)error {
@@ -216,11 +255,13 @@ - (GTBranch *)reloadedBranchWithError:(NSError **)error {
216255
GTReference *reloadedRef = [self.reference reloadedReferenceWithError:error];
217256
if (reloadedRef == nil) return nil;
218257

219-
return [[self.class alloc] initWithReference:reloadedRef repository:self.repository];
258+
return [[self.class alloc] initWithReference:reloadedRef];
220259
}
221260

222261
- (BOOL)calculateAhead:(size_t *)ahead behind:(size_t *)behind relativeTo:(GTBranch *)branch error:(NSError **)error {
223-
return [self.repository calculateAhead:ahead behind:behind ofOID:self.OID relativeToOID:branch.OID error:error];
262+
GTOID *oid = self.OID;
263+
GTOID *branchOID = branch.OID;
264+
return [self.repository calculateAhead:ahead behind:behind ofOID:oid relativeToOID:branchOID error:error];
224265
}
225266

226267
@end

ObjectiveGit/GTCheckoutOptions.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ typedef NS_OPTIONS(NSInteger, GTCheckoutNotifyFlags) {
8787
@property (assign) GTCheckoutStrategyType strategy;
8888

8989
/// The checkout progress block that was passed in.
90-
@property (copy) void (^progressBlock)(NSString *path, NSUInteger completedSteps, NSUInteger totalSteps);
90+
@property (copy, nullable) void (^progressBlock)(NSString *path, NSUInteger completedSteps, NSUInteger totalSteps);
9191

9292
/// The notification flags currently enabled.
9393
@property (assign) GTCheckoutNotifyFlags notifyFlags;
9494

9595
/// The checkout notification block that was passed in.
96-
@property (copy) int (^notifyBlock)(GTCheckoutNotifyFlags why, NSString *path, GTDiffFile *baseline, GTDiffFile *target, GTDiffFile *workdir);
96+
@property (copy, nullable) int (^notifyBlock)(GTCheckoutNotifyFlags why, NSString *path, GTDiffFile *baseline, GTDiffFile *target, GTDiffFile *workdir);
9797

9898
/// An array of strings used to restrict what will be checked out.
9999
@property (copy) NSArray <NSString *> *pathSpecs;

ObjectiveGit/GTCommit.h

+2
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ NS_ASSUME_NONNULL_BEGIN
3939

4040
@interface GTCommit : GTObject {}
4141

42+
@property (nonatomic, readonly, strong) GTOID *OID;
4243
@property (nonatomic, readonly, strong) GTSignature * _Nullable author;
4344
@property (nonatomic, readonly, strong) GTSignature * _Nullable committer;
4445
@property (nonatomic, readonly, copy) NSArray<GTCommit *> *parents;
46+
@property (nonatomic, readonly, copy) NSArray<GTOID *> *parentOIDs;
4547
@property (nonatomic, readonly) NSString * _Nullable message;
4648
@property (nonatomic, readonly) NSString *messageDetails;
4749
@property (nonatomic, readonly) NSString *messageSummary;

0 commit comments

Comments
 (0)