Skip to content

Commit 8b5b37d

Browse files
committed
Merge pull request #355 from libgit2/purgatory
libgit2 updates, reset fixes, etc. etc.
2 parents 392eff9 + 584ff60 commit 8b5b37d

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

Classes/GTDiffFile.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ typedef enum {
4545
// The git_diff_file represented by the receiver.
4646
@property (nonatomic, readonly) git_diff_file git_diff_file;
4747

48-
// Designated initialiser.
48+
/// Initializes the receiver with the provided libgit2 object.
49+
///
50+
/// file - The git_diff_file wrapped by the receiver.
51+
///
52+
/// Returns an initialized GTDiffFile.
4953
- (instancetype)initWithGitDiffFile:(git_diff_file)file;
5054

5155
@end

Classes/GTDiffFile.m

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,19 @@
1212
@implementation GTDiffFile
1313

1414
- (instancetype)initWithGitDiffFile:(git_diff_file)file {
15+
NSParameterAssert(file.path != NULL);
16+
1517
self = [super init];
1618
if (self == nil) return nil;
17-
19+
20+
_path = [NSFileManager.defaultManager stringWithFileSystemRepresentation:file.path length:strlen(file.path)];
21+
if (_path == nil) return nil;
22+
1823
_git_diff_file = file;
19-
2024
_size = (NSUInteger)file.size;
2125
_flags = (GTDiffFileFlag)file.flags;
2226
_mode = file.mode;
23-
_path = [NSString stringWithUTF8String:file.path];
24-
27+
2528
return self;
2629
}
2730

Classes/GTSubmodule.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ - (NSString *)URLString {
7272
#pragma mark Lifecycle
7373

7474
- (void)dealloc {
75-
git_submodule_free(_git_submodule);
75+
if (_git_submodule != NULL) {
76+
git_submodule_free(_git_submodule);
77+
}
7678
}
7779

7880
- (id)initWithGitSubmodule:(git_submodule *)submodule parentRepository:(GTRepository *)repository {

ObjectiveGitTests/GTSubmoduleSpec.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@
6666
expect(@(git_submodule_url(submodule.git_submodule))).notTo.equal(testURLString);
6767

6868
git_submodule_set_url(submodule.git_submodule, testURLString.UTF8String);
69-
69+
git_submodule_save(submodule.git_submodule);
70+
7071
__block NSError *error = nil;
7172
expect([submodule writeToParentConfigurationDestructively:YES error:&error]).to.beTruthy();
7273
expect(error).to.beNil();
@@ -87,9 +88,6 @@
8788
[gitmodules appendString:@"[submodule \"new_submodule\"]\n\turl = some_url\n\tpath = new_submodule_path"];
8889
expect([gitmodules writeToURL:gitmodulesURL atomically:YES encoding:NSUTF8StringEncoding error:NULL]).to.beTruthy();
8990

90-
submodule = [repo submoduleWithName:@"new_submodule" error:NULL];
91-
expect(submodule).to.beNil();
92-
9391
__block NSError *error = nil;
9492
expect([repo reloadSubmodules:&error]).to.beTruthy();
9593
expect(error).to.beNil();

0 commit comments

Comments
 (0)