Skip to content

Commit 367ad42

Browse files
committed
Changed parameters types
1 parent d0bcc78 commit 367ad42

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

ObjectiveGit/GTRepository.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ extern NSString *const GTRepositoryCloneOptionsServerCertificateURL;
114114
/// +initWithURL:flags:ceilingDirs:error:.
115115
///
116116
/// See respository.h for documentation of each individual flag.
117-
typedef NS_OPTIONS(UInt32, GTRepositoryOpenFlags) {
117+
typedef NS_OPTIONS(NSInteger, GTRepositoryOpenFlags) {
118118
GTRepositoryOpenNoSearch = GIT_REPOSITORY_OPEN_NO_SEARCH,
119119
GTRepositoryOpenCrossFS = GIT_REPOSITORY_OPEN_CROSS_FS,
120120
GTRepositoryOpenBare = GIT_REPOSITORY_OPEN_BARE,
@@ -221,15 +221,14 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) {
221221

222222
/// Convenience initializer to find and open a repository with extended controls.
223223
///
224-
/// localFileURL - The file URL for the new repository. Cannot be nil.
225-
/// flags - A combination of the `GTRepositoryOpenFlags` flags.
226-
/// ceilingDirs - A GIT_PATH_LIST_SEPARATOR delimited list of path prefixes at
227-
/// which the search for a containing repository should terminate.
228-
/// Can be NULL.
229-
/// error - The error if one occurs.
224+
/// localFileURL - The file URL for the new repository. Cannot be nil.
225+
/// flags - A combination of the `GTRepositoryOpenFlags` flags.
226+
/// ceilingDirURLs - An array of URLs at which the search for a containing
227+
/// repository should terminate. Can be NULL.
228+
/// error - The error if one occurs.
230229
///
231230
/// Returns the initialized repository, or nil if an error occurred.
232-
- (nullable instancetype)initWithURL:(NSURL *)localFileURL flags:(UInt32)flags ceilingDirs:(nullable const char *)ceilingDirs error:(NSError **)error;
231+
- (nullable instancetype)initWithURL:(NSURL *)localFileURL flags:(NSInteger)flags ceilingDirs:(nullable NSArray<NSURL *> *)ceilingDirURLs error:(NSError **)error;
233232

234233
- (instancetype)init NS_UNAVAILABLE;
235234

ObjectiveGit/GTRepository.m

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,27 @@ - (instancetype)initWithURL:(NSURL *)localFileURL error:(NSError **)error {
177177
return [self initWithGitRepository:r];
178178
}
179179

180-
- (instancetype)initWithURL:(NSURL *)localFileURL flags:(UInt32)flags ceilingDirs:(const char *)ceilingDirs error:(NSError **)error {
180+
- (instancetype)initWithURL:(NSURL *)localFileURL flags:(NSInteger)flags ceilingDirs:(NSArray<NSURL *> *)ceilingDirURLs error:(NSError **)error {
181181
if (!localFileURL.isFileURL || localFileURL.path == nil) {
182-
if (error != NULL) *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnsupportedSchemeError userInfo:@{ NSLocalizedDescriptionKey: NSLocalizedString(@"Invalid file path URL to initialize repository.", @"") }];
182+
if (error != NULL) *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnsupportedSchemeError userInfo:@{ NSLocalizedDescriptionKey: NSLocalizedString(@"Invalid file path URL to open.", @"") }];
183183
return nil;
184184
}
185185

186+
// Concatenate URL paths.
187+
NSMutableString *ceilingDirsString;
188+
if (ceilingDirURLs.count > 0) {
189+
ceilingDirsString = [[NSMutableString alloc] init];
190+
[ceilingDirURLs enumerateObjectsUsingBlock:^(NSURL * _Nonnull url, NSUInteger idx, BOOL * _Nonnull stop) {
191+
if (idx < ceilingDirURLs.count - 1) {
192+
[ceilingDirsString appendString:[NSString stringWithFormat:@"%@%c", url.path, GIT_PATH_LIST_SEPARATOR]];
193+
} else {
194+
[ceilingDirsString appendString:url.path];
195+
}
196+
}];
197+
}
198+
186199
git_repository *r;
187-
int gitError = git_repository_open_ext(&r, localFileURL.path.fileSystemRepresentation, flags, ceilingDirs);
200+
int gitError = git_repository_open_ext(&r, localFileURL.path.fileSystemRepresentation, (unsigned int)flags, ceilingDirsString.fileSystemRepresentation);
188201
if (gitError < GIT_OK) {
189202
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to open repository at URL %@.", localFileURL];
190203
return nil;

0 commit comments

Comments
 (0)