Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions GitUpKit/Core/GCRepository.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ typedef NS_ENUM(NSUInteger, GCFileMode) {
@property(nonatomic, readonly) GCRepositoryState state; // Do NOT use on a bare repository
- (instancetype)initWithExistingLocalRepository:(NSString*)path error:(NSError**)error;
- (instancetype)initWithNewLocalRepository:(NSString*)path bare:(BOOL)bare error:(NSError**)error; // git init {path}
- (instancetype)initWithNewLocalRepository:(NSString*)path bare:(BOOL)bare defaultBranchName:(NSString*)defaultBranchName error:(NSError**)error;

- (BOOL)cleanupState:(NSError**)error; // Do NOT use on a bare repository

Expand Down
9 changes: 9 additions & 0 deletions GitUpKit/Core/GCRepository.m
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,20 @@ - (instancetype)initWithExistingLocalRepository:(NSString*)path error:(NSError**
}

- (instancetype)initWithNewLocalRepository:(NSString*)path bare:(BOOL)bare error:(NSError**)error {
return [self initWithNewLocalRepository:path bare:bare defaultBranchName:nil error:error];
}

- (instancetype)initWithNewLocalRepository:(NSString*)path bare:(BOOL)bare defaultBranchName:(NSString*)defaultBranchName error:(NSError**)error {
git_repository_init_options options = GIT_REPOSITORY_INIT_OPTIONS_INIT;
options.flags = GIT_REPOSITORY_INIT_NO_REINIT | GIT_REPOSITORY_INIT_MKPATH;
if (bare) {
options.flags |= GIT_REPOSITORY_INIT_BARE;
}

if (defaultBranchName) {
options.initial_head = defaultBranchName.UTF8String;
}

git_repository* repository;
CALL_LIBGIT2_FUNCTION_RETURN(nil, git_repository_init_ext, &repository, path.fileSystemRepresentation, &options);
return [self initWithRepository:repository error:error];
Expand Down
2 changes: 1 addition & 1 deletion GitUpKit/Core/GCTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ - (void)setUp {
}

- (GCRepository*)createLocalRepositoryAtPath:(NSString*)path bare:(BOOL)bare {
GCRepository* repo = [[GCRepository alloc] initWithNewLocalRepository:path bare:bare error:NULL];
GCRepository* repo = [[GCRepository alloc] initWithNewLocalRepository:path bare:bare defaultBranchName:@"master" error:NULL];
XCTAssertNotNil(repo);

NSString* configDirectory = [[NSTemporaryDirectory() stringByAppendingPathComponent:[[NSProcessInfo processInfo] globallyUniqueString]] stringByAppendingPathComponent:@"git"];
Expand Down