File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -128,7 +128,6 @@ + (instancetype)initializeEmptyRepositoryAtFileURL:(NSURL *)localFileURL options
128128 }
129129
130130 git_repository_init_options options = GIT_REPOSITORY_INIT_OPTIONS_INIT;
131- options.flags = (uint32_t )[optionsDict[GTRepositoryInitOptionsFlags] unsignedIntegerValue ];
132131 options.mode = (uint32_t )
133132 [optionsDict[GTRepositoryInitOptionsMode] unsignedIntegerValue ];
134133 options.workdir_path = [optionsDict[GTRepositoryInitWorkingDirectoryPath] UTF8String ];
@@ -137,6 +136,10 @@ + (instancetype)initializeEmptyRepositoryAtFileURL:(NSURL *)localFileURL options
137136 options.initial_head = [optionsDict[GTRepositoryInitInitialHEAD] UTF8String ];
138137 options.origin_url = [optionsDict[GTRepositoryInitOriginURLString] UTF8String ];
139138
139+ // This default mirrors git_repository_init().
140+ NSNumber *flags = optionsDict[GTRepositoryInitOptionsFlags];
141+ options.flags = (flags == nil ? GIT_REPOSITORY_INIT_MKPATH : (uint32_t )flags.unsignedIntegerValue );
142+
140143 const char *path = localFileURL.path .fileSystemRepresentation ;
141144 git_repository *repository = NULL ;
142145 int gitError = git_repository_init_ext (&repository, path, &options);
Original file line number Diff line number Diff line change 2525 it (@" should initialize a repository with a working directory by default" , ^{
2626 NSURL *newRepoURL = [self .tempDirectoryFileURL URLByAppendingPathComponent: @" init-repo" ];
2727
28- GTRepository *repository = [GTRepository initializeEmptyRepositoryAtFileURL: newRepoURL options: nil error: NULL ];
28+ NSError *error;
29+ GTRepository *repository = [GTRepository initializeEmptyRepositoryAtFileURL: newRepoURL options: nil error: &error];
2930 expect (repository).notTo (beNil ());
31+ expect (error).to (beNil ());
32+
3033 expect (repository.gitDirectoryURL ).notTo (beNil ());
3134 expect (@(repository.bare )).to (beFalsy ());
3235 });
3740 GTRepositoryInitOptionsFlags: @(GTRepositoryInitBare)
3841 };
3942
40- GTRepository *repository = [GTRepository initializeEmptyRepositoryAtFileURL: newRepoURL options: options error: NULL ];
43+ NSError *error;
44+ GTRepository *repository = [GTRepository initializeEmptyRepositoryAtFileURL: newRepoURL options: options error: &error];
4145 expect (repository).notTo (beNil ());
46+ expect (error).to (beNil ());
47+
4248 expect (repository.gitDirectoryURL ).notTo (beNil ());
4349 expect (@(repository.bare )).to (beTruthy ());
4450 });
203209 NSError *error = nil ;
204210 NSURL *fileURL = [self .tempDirectoryFileURL URLByAppendingPathComponent: @" newrepo" ];
205211 GTRepository *newRepo = [GTRepository initializeEmptyRepositoryAtFileURL: fileURL options: nil error: &error];
212+ expect (newRepo).notTo (beNil ());
206213 expect (@(newRepo.isEmpty )).to (beTruthy ());
207214 [NSFileManager .defaultManager removeItemAtURL: fileURL error: NULL ];
208215 });
You can’t perform that action at this time.
0 commit comments