Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/git-up/GitUp
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Apr 24, 2024
2 parents 8c59d57 + aabbc8a commit d7fdc2f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
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

0 comments on commit d7fdc2f

Please sign in to comment.