Skip to content

Commit 13c32cb

Browse files
committed
Merge pull request #446 from libgit2/bump-libgit2-to-fix-status-item-crash
Bump libgit2.
2 parents 3f617c5 + 278a0fe commit 13c32cb

14 files changed

+43
-48
lines changed

External/libgit2

Submodule libgit2 updated 283 files

ObjectiveGit/GTConfiguration.m

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
#import "GTConfiguration+Private.h"
1111
#import "GTRepository.h"
1212
#import "GTRemote.h"
13-
#import "NSError+Git.h"
1413
#import "GTSignature.h"
14+
#import "NSData+Git.h"
15+
#import "NSError+Git.h"
1516

1617
#import "git2/config.h"
1718
#import "git2/errors.h"
19+
#import "git2/buffer.h"
1820

1921
@interface GTConfiguration ()
2022
@property (nonatomic, readonly, assign) git_config *git_config;
@@ -58,11 +60,10 @@ - (void)setString:(NSString *)s forKey:(NSString *)key {
5860
}
5961

6062
- (NSString *)stringForKey:(NSString *)key {
61-
const char *string = NULL;
62-
git_config_get_string(&string, self.git_config, key.UTF8String);
63-
if (string == NULL) return nil;
63+
git_buf buffer = {};
64+
if (git_config_get_string_buf(&buffer, self.git_config, key.UTF8String) != 0) return nil;
6465

65-
return [NSString stringWithUTF8String:string];
66+
return [[NSString alloc] initWithData:[NSData git_dataWithBuffer:&buffer] encoding:NSUTF8StringEncoding];
6667
}
6768

6869
- (void)setBool:(BOOL)b forKey:(NSString *)key {

ObjectiveGit/GTFilterList.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
/// The options for loading a filter list. See libgit2 for more information.
1616
typedef NS_OPTIONS(NSInteger, GTFilterListOptions) {
17-
GTFilterListOptionsDefault = GIT_FILTER_OPT_DEFAULT,
18-
GTFilterListOptionsAllowUnsafe = GIT_FILTER_OPT_ALLOW_UNSAFE,
17+
GTFilterListOptionsDefault = GIT_FILTER_DEFAULT,
18+
GTFilterListOptionsAllowUnsafe = GIT_FILTER_ALLOW_UNSAFE,
1919
};
2020

2121
/// An opaque list of filters that apply to a given path.

ObjectiveGit/GTFilterList.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ - (NSData *)applyToPath:(NSString *)relativePath inRepository:(GTRepository *)re
6565
NSParameterAssert(repository != nil);
6666

6767
git_buf output = GIT_BUF_INIT_CONST(0, NULL);
68-
int gitError = git_filter_list_apply_to_file(&output, self.git_filter_list, repository.git_repository, relativePath.UTF8String);
68+
// fixme: This is a workaround for an issue where `git_filter_list_apply_to_file`
69+
// will not resolve relative paths against the worktree. It should be reverted when
70+
// libgit2 has been updated to resolve that.
71+
NSString *absolutePath = relativePath.absolutePath ? relativePath : [repository.fileURL URLByAppendingPathComponent:relativePath].path;
72+
int gitError = git_filter_list_apply_to_file(&output, self.git_filter_list, repository.git_repository, absolutePath.UTF8String);
6973

7074
if (gitError != GIT_OK) {
7175
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to apply filter list to %@", relativePath];

ObjectiveGit/GTReference.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
@class GTOID;
3030
@class GTReflog;
31-
@class GTSignature;
3231

3332
typedef NS_ENUM(NSInteger, GTReferenceErrorCode) {
3433
GTReferenceErrorCodeInvalidReference = -4,
@@ -89,14 +88,12 @@ typedef NS_OPTIONS(NSInteger, GTReferenceType) {
8988
/// Note that this does *not* change the receiver's target.
9089
///
9190
/// newTarget - The target for the new reference. This must not be nil.
92-
/// signature - A signature for the committer updating this ref, used for
93-
/// creating a reflog entry. This may be nil.
9491
/// message - A message to use when creating the reflog entry for this action.
9592
/// This may be nil.
9693
/// error - The error if one occurred.
9794
///
9895
/// Returns the updated reference, or nil if an error occurred.
99-
- (GTReference *)referenceByUpdatingTarget:(NSString *)newTarget committer:(GTSignature *)signature message:(NSString *)message error:(NSError **)error;
96+
- (GTReference *)referenceByUpdatingTarget:(NSString *)newTarget message:(NSString *)message error:(NSError **)error;
10097

10198
/// The name of the reference.
10299
@property (nonatomic, readonly, copy) NSString *name;

ObjectiveGit/GTReference.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ - (GTReference *)referenceByRenaming:(NSString *)newName error:(NSError **)error
128128
NSParameterAssert(newName != nil);
129129

130130
git_reference *newRef = NULL;
131-
int gitError = git_reference_rename(&newRef, self.git_reference, newName.UTF8String, 0, [self.repository userSignatureForNow].git_signature, NULL);
131+
int gitError = git_reference_rename(&newRef, self.git_reference, newName.UTF8String, 0, NULL);
132132
if (gitError != GIT_OK) {
133133
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to rename reference %@ to %@.", self.name, newName];
134134
return nil;
@@ -173,7 +173,7 @@ - (NSString *)targetSHA {
173173
return [self.resolvedTarget SHA];
174174
}
175175

176-
- (GTReference *)referenceByUpdatingTarget:(NSString *)newTarget committer:(GTSignature *)signature message:(NSString *)message error:(NSError **)error {
176+
- (GTReference *)referenceByUpdatingTarget:(NSString *)newTarget message:(NSString *)message error:(NSError **)error {
177177
NSParameterAssert(newTarget != nil);
178178

179179
int gitError;
@@ -182,9 +182,9 @@ - (GTReference *)referenceByUpdatingTarget:(NSString *)newTarget committer:(GTSi
182182
GTOID *oid = [[GTOID alloc] initWithSHA:newTarget error:error];
183183
if (oid == nil) return nil;
184184

185-
gitError = git_reference_set_target(&newRef, self.git_reference, oid.git_oid, signature.git_signature, message.UTF8String);
185+
gitError = git_reference_set_target(&newRef, self.git_reference, oid.git_oid, message.UTF8String);
186186
} else {
187-
gitError = git_reference_symbolic_set_target(&newRef, self.git_reference, newTarget.UTF8String, signature.git_signature, message.UTF8String);
187+
gitError = git_reference_symbolic_set_target(&newRef, self.git_reference, newTarget.UTF8String, message.UTF8String);
188188
}
189189

190190
if (gitError != GIT_OK) {

ObjectiveGit/GTRepository+RemoteOperations.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ - (BOOL)fetchRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error
9595
git_strarray_free(&refspecs);
9696
};
9797

98-
gitError = git_remote_fetch(remote.git_remote, &refspecs, self.userSignatureForNow.git_signature, NULL);
98+
gitError = git_remote_fetch(remote.git_remote, &refspecs, NULL);
9999
if (gitError != GIT_OK) {
100100
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to fetch from remote"];
101101
return NO;
@@ -246,7 +246,7 @@ - (BOOL)pushRefspecs:(NSArray *)refspecs toRemote:(GTRemote *)remote withOptions
246246
return NO;
247247
}
248248

249-
gitError = git_remote_update_tips(remote.git_remote, self.userSignatureForNow.git_signature, NULL);
249+
gitError = git_remote_update_tips(remote.git_remote, NULL);
250250
if (gitError != GIT_OK) {
251251
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Update tips failed"];
252252
return NO;

ObjectiveGit/GTRepository+Reset.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ - (BOOL)resetToCommit:(GTCommit *)commit resetType:(GTRepositoryResetType)resetT
2020
NSParameterAssert(commit != nil);
2121

2222
git_checkout_options options = GIT_CHECKOUT_OPTIONS_INIT;
23-
int gitError = git_reset(self.git_repository, commit.git_object, (git_reset_t)resetType, &options, (git_signature *)[self userSignatureForNow].git_signature, NULL);
23+
int gitError = git_reset(self.git_repository, commit.git_object, (git_reset_t)resetType, &options);
2424
if (gitError != GIT_OK) {
2525
if (error != NULL) {
2626
*error = [NSError git_errorFor:gitError description:@"Failed to reset repository to commit %@.", commit.SHA];

ObjectiveGit/GTRepository.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
typedef NS_OPTIONS(NSInteger, GTCheckoutStrategyType) {
5858
GTCheckoutStrategyNone = GIT_CHECKOUT_NONE,
5959
GTCheckoutStrategySafe = GIT_CHECKOUT_SAFE,
60-
GTCheckoutStrategySafeCreate = GIT_CHECKOUT_SAFE_CREATE,
6160
GTCheckoutStrategyForce = GIT_CHECKOUT_FORCE,
6261
GTCheckoutStrategyAllowConflicts = GIT_CHECKOUT_ALLOW_CONFLICTS,
6362
GTCheckoutStrategyRemoveUntracked = GIT_CHECKOUT_REMOVE_UNTRACKED,
@@ -279,41 +278,35 @@ extern NSString * const GTRepositoryInitOptionsOriginURLString;
279278
///
280279
/// name - The full name for the new reference. This must not be nil.
281280
/// targetOID - The OID that the new ref should point to. This must not be nil.
282-
/// signature - A signature for the committer creating this ref, used for
283-
/// creating a reflog entry. This may be nil.
284281
/// message - A message to use when creating the reflog entry for this action.
285282
/// This may be nil.
286283
/// error - If not NULL, set to any error that occurs.
287284
///
288285
/// Returns the created ref, or nil if an error occurred.
289-
- (GTReference *)createReferenceNamed:(NSString *)name fromOID:(GTOID *)targetOID committer:(GTSignature *)signature message:(NSString *)message error:(NSError **)error;
286+
- (GTReference *)createReferenceNamed:(NSString *)name fromOID:(GTOID *)targetOID message:(NSString *)message error:(NSError **)error;
290287

291288
/// Creates a symbolic reference to another ref.
292289
///
293290
/// name - The full name for the new reference. This must not be nil.
294291
/// targetRef - The ref that the new ref should point to. This must not be nil.
295-
/// signature - A signature for the committer creating this ref, used for
296-
/// creating a reflog entry. This may be nil.
297292
/// message - A message to use when creating the reflog entry for this action.
298293
/// This may be nil.
299294
/// error - If not NULL, set to any error that occurs.
300295
///
301296
/// Returns the created ref, or nil if an error occurred.
302-
- (GTReference *)createReferenceNamed:(NSString *)name fromReference:(GTReference *)targetRef committer:(GTSignature *)signature message:(NSString *)message error:(NSError **)error;
297+
- (GTReference *)createReferenceNamed:(NSString *)name fromReference:(GTReference *)targetRef message:(NSString *)message error:(NSError **)error;
303298

304299
/// Create a new local branch pointing to the given OID.
305300
///
306301
/// name - The name for the new branch (e.g., `master`). This must not be
307302
/// nil.
308303
/// targetOID - The OID to create the new branch off. This must not be nil.
309-
/// signature - A signature for the committer creating this branch, used for
310-
/// creating a reflog entry. This may be nil.
311304
/// message - A message to use when creating the reflog entry for this action.
312305
/// This may be nil.
313306
/// error - If not NULL, set to any error that occurs.
314307
///
315308
/// Returns the new branch, or nil if an error occurred.
316-
- (GTBranch *)createBranchNamed:(NSString *)name fromOID:(GTOID *)targetOID committer:(GTSignature *)signature message:(NSString *)message error:(NSError **)error;
309+
- (GTBranch *)createBranchNamed:(NSString *)name fromOID:(GTOID *)targetOID message:(NSString *)message error:(NSError **)error;
317310

318311
/// Get the current branch.
319312
///

ObjectiveGit/GTRepository.m

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ + (id)cloneFromURL:(NSURL *)originURL toWorkingDirectory:(NSURL *)workdirURL opt
236236

237237
if (withCheckout) {
238238
git_checkout_options checkoutOptions = GIT_CHECKOUT_OPTIONS_INIT;
239-
checkoutOptions.checkout_strategy = GIT_CHECKOUT_SAFE_CREATE;
239+
checkoutOptions.checkout_strategy = GIT_CHECKOUT_SAFE;
240240
checkoutOptions.progress_cb = checkoutProgressCallback;
241241
checkoutOptions.progress_payload = (__bridge void *)checkoutProgressBlock;
242242
cloneOptions.checkout_opts = checkoutOptions;
@@ -493,12 +493,12 @@ - (NSUInteger)numberOfCommitsInCurrentBranch:(NSError **)error {
493493
return [currentBranch numberOfCommitsWithError:error];
494494
}
495495

496-
- (GTReference *)createReferenceNamed:(NSString *)name fromOID:(GTOID *)targetOID committer:(GTSignature *)signature message:(NSString *)message error:(NSError **)error {
496+
- (GTReference *)createReferenceNamed:(NSString *)name fromOID:(GTOID *)targetOID message:(NSString *)message error:(NSError **)error {
497497
NSParameterAssert(name != nil);
498498
NSParameterAssert(targetOID != nil);
499499

500500
git_reference *ref;
501-
int gitError = git_reference_create(&ref, self.git_repository, name.UTF8String, targetOID.git_oid, 0, signature.git_signature, message.UTF8String);
501+
int gitError = git_reference_create(&ref, self.git_repository, name.UTF8String, targetOID.git_oid, 0, message.UTF8String);
502502
if (gitError != GIT_OK) {
503503
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to create direct reference to %@", targetOID];
504504
return nil;
@@ -507,13 +507,13 @@ - (GTReference *)createReferenceNamed:(NSString *)name fromOID:(GTOID *)targetOI
507507
return [[GTReference alloc] initWithGitReference:ref repository:self];
508508
}
509509

510-
- (GTReference *)createReferenceNamed:(NSString *)name fromReference:(GTReference *)targetRef committer:(GTSignature *)signature message:(NSString *)message error:(NSError **)error {
510+
- (GTReference *)createReferenceNamed:(NSString *)name fromReference:(GTReference *)targetRef message:(NSString *)message error:(NSError **)error {
511511
NSParameterAssert(name != nil);
512512
NSParameterAssert(targetRef != nil);
513513
NSParameterAssert(targetRef.name != nil);
514514

515515
git_reference *ref;
516-
int gitError = git_reference_symbolic_create(&ref, self.git_repository, name.UTF8String, targetRef.name.UTF8String, 0, signature.git_signature, message.UTF8String);
516+
int gitError = git_reference_symbolic_create(&ref, self.git_repository, name.UTF8String, targetRef.name.UTF8String, 0, message.UTF8String);
517517
if (gitError != GIT_OK) {
518518
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to create symbolic reference to %@", targetRef];
519519
return nil;
@@ -522,11 +522,11 @@ - (GTReference *)createReferenceNamed:(NSString *)name fromReference:(GTReferenc
522522
return [[GTReference alloc] initWithGitReference:ref repository:self];
523523
}
524524

525-
- (GTBranch *)createBranchNamed:(NSString *)name fromOID:(GTOID *)targetOID committer:(GTSignature *)signature message:(NSString *)message error:(NSError **)error {
525+
- (GTBranch *)createBranchNamed:(NSString *)name fromOID:(GTOID *)targetOID message:(NSString *)message error:(NSError **)error {
526526
NSParameterAssert(name != nil);
527527
NSParameterAssert(targetOID != nil);
528528

529-
GTReference *newRef = [self createReferenceNamed:[GTBranch.localNamePrefix stringByAppendingString:name] fromOID:targetOID committer:signature message:message error:error];
529+
GTReference *newRef = [self createReferenceNamed:[GTBranch.localNamePrefix stringByAppendingString:name] fromOID:targetOID message:message error:error];
530530
if (newRef == nil) return nil;
531531

532532
return [GTBranch branchWithReference:newRef repository:self];
@@ -800,7 +800,7 @@ static int checkoutNotifyCallback(git_checkout_notify_t why, const char *path, c
800800
- (BOOL)moveHEADToReference:(GTReference *)reference error:(NSError **)error {
801801
NSParameterAssert(reference != nil);
802802

803-
int gitError = git_repository_set_head(self.git_repository, reference.name.UTF8String, [self userSignatureForNow].git_signature, NULL);
803+
int gitError = git_repository_set_head(self.git_repository, reference.name.UTF8String);
804804
if (gitError != GIT_OK) {
805805
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to move HEAD to reference %@", reference.name];
806806
}
@@ -811,7 +811,7 @@ - (BOOL)moveHEADToReference:(GTReference *)reference error:(NSError **)error {
811811
- (BOOL)moveHEADToCommit:(GTCommit *)commit error:(NSError **)error {
812812
NSParameterAssert(commit != nil);
813813

814-
int gitError = git_repository_set_head_detached(self.git_repository, commit.OID.git_oid, [self userSignatureForNow].git_signature, NULL);
814+
int gitError = git_repository_set_head_detached(self.git_repository, commit.OID.git_oid);
815815
if (gitError != GIT_OK) {
816816
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to move HEAD to commit %@", commit.SHA];
817817
}

0 commit comments

Comments
 (0)