diff options
Diffstat (limited to 'tests/test_helpers.c')
| -rw-r--r-- | tests/test_helpers.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/tests/test_helpers.c b/tests/test_helpers.c index 4805fdcae..588461135 100644 --- a/tests/test_helpers.c +++ b/tests/test_helpers.c @@ -197,7 +197,7 @@ static int remove_filesystem_element_recurs(void *GIT_UNUSED(nil), char *path) return gitfo_unlink(path); } -int rmdir_recurs(char *directory_path) +int rmdir_recurs(const char *directory_path) { char buffer[GIT_PATH_MAX]; strcpy(buffer, directory_path); @@ -227,7 +227,7 @@ static int copy_filesystem_element_recurs(void *_data, char *source) return copy_file(source, data->dst); } -int copydir_recurs(char *source_directory_path, char *destination_directory_path) +int copydir_recurs(const char *source_directory_path, const char *destination_directory_path) { char source_buffer[GIT_PATH_MAX]; char dest_buffer[GIT_PATH_MAX]; @@ -246,3 +246,18 @@ int copydir_recurs(char *source_directory_path, char *destination_directory_path return copy_filesystem_element_recurs(&data, source_buffer); } + +int open_temp_repo(git_repository **repo, const char *path) +{ + int error; + if ((error = copydir_recurs(path, TEMP_REPO_FOLDER)) < GIT_SUCCESS) + return error; + + return git_repository_open(repo, TEMP_REPO_FOLDER); +} + +void close_temp_repo(git_repository *repo) +{ + git_repository_free(repo); + rmdir_recurs(TEMP_REPO_FOLDER); +} |
