Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Changed parameters types
  • Loading branch information
glegrain committed Oct 31, 2016
commit 367ad428e014a67697d2b79fdd5440ceb7cf0c5d
15 changes: 7 additions & 8 deletions ObjectiveGit/GTRepository.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ extern NSString *const GTRepositoryCloneOptionsServerCertificateURL;
/// +initWithURL:flags:ceilingDirs:error:.
///
/// See respository.h for documentation of each individual flag.
typedef NS_OPTIONS(UInt32, GTRepositoryOpenFlags) {
typedef NS_OPTIONS(NSInteger, GTRepositoryOpenFlags) {
GTRepositoryOpenNoSearch = GIT_REPOSITORY_OPEN_NO_SEARCH,
GTRepositoryOpenCrossFS = GIT_REPOSITORY_OPEN_CROSS_FS,
GTRepositoryOpenBare = GIT_REPOSITORY_OPEN_BARE,
Expand Down Expand Up @@ -221,15 +221,14 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) {

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

- (instancetype)init NS_UNAVAILABLE;

Expand Down
19 changes: 16 additions & 3 deletions ObjectiveGit/GTRepository.m
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,27 @@ - (instancetype)initWithURL:(NSURL *)localFileURL error:(NSError **)error {
return [self initWithGitRepository:r];
}

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

// Concatenate URL paths.
NSMutableString *ceilingDirsString;
if (ceilingDirURLs.count > 0) {
ceilingDirsString = [[NSMutableString alloc] init];
[ceilingDirURLs enumerateObjectsUsingBlock:^(NSURL * _Nonnull url, NSUInteger idx, BOOL * _Nonnull stop) {
if (idx < ceilingDirURLs.count - 1) {
[ceilingDirsString appendString:[NSString stringWithFormat:@"%@%c", url.path, GIT_PATH_LIST_SEPARATOR]];
} else {
[ceilingDirsString appendString:url.path];
}
}];
}

git_repository *r;
int gitError = git_repository_open_ext(&r, localFileURL.path.fileSystemRepresentation, flags, ceilingDirs);
int gitError = git_repository_open_ext(&r, localFileURL.path.fileSystemRepresentation, (unsigned int)flags, ceilingDirsString.fileSystemRepresentation);
if (gitError < GIT_OK) {
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to open repository at URL %@.", localFileURL];
return nil;
Expand Down