Commit eb2f3b47 by nulltoken Committed by Vicent Marti

Made git_repository_open2() and git_repository_open3() benefit from recently…

Made git_repository_open2() and git_repository_open3() benefit from recently added path prettifying function.
parent 618818dc
...@@ -94,31 +94,34 @@ static int assign_repository_DIRs(git_repository *repo, ...@@ -94,31 +94,34 @@ static int assign_repository_DIRs(git_repository *repo,
const char *git_work_tree) const char *git_work_tree)
{ {
char path_aux[GIT_PATH_MAX]; char path_aux[GIT_PATH_MAX];
size_t path_len; size_t git_dir_path_len;
int error = GIT_SUCCESS;
assert(repo); assert(repo);
if (git_dir == NULL || gitfo_isdir(git_dir) < GIT_SUCCESS) if (git_dir == NULL)
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
/* store GIT_DIR */ error = git_prettify_dir_path(path_aux, git_dir);
path_len = strlen(git_dir); if (error < GIT_SUCCESS)
strcpy(path_aux, git_dir); return error;
if (path_aux[path_len - 1] != '/') {
path_aux[path_len] = '/';
path_aux[path_len + 1] = 0;
path_len = path_len + 1; if (gitfo_isdir(path_aux) < GIT_SUCCESS)
} return GIT_ENOTFOUND;
git_dir_path_len = strlen(path_aux);
/* store GIT_DIR */
repo->path_repository = git__strdup(path_aux); repo->path_repository = git__strdup(path_aux);
/* store GIT_OBJECT_DIRECTORY */ /* store GIT_OBJECT_DIRECTORY */
if (git_object_directory == NULL) if (git_object_directory == NULL)
strcpy(path_aux + path_len, GIT_OBJECTS_DIR); strcpy(repo->path_repository + git_dir_path_len, GIT_OBJECTS_DIR);
else else {
strcpy(path_aux, git_object_directory); error = git_prettify_dir_path(path_aux, git_object_directory);
if (error < GIT_SUCCESS)
return error;
}
if (gitfo_isdir(path_aux) < GIT_SUCCESS) if (gitfo_isdir(path_aux) < GIT_SUCCESS)
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
...@@ -128,9 +131,12 @@ static int assign_repository_DIRs(git_repository *repo, ...@@ -128,9 +131,12 @@ static int assign_repository_DIRs(git_repository *repo,
/* store GIT_INDEX_FILE */ /* store GIT_INDEX_FILE */
if (git_index_file == NULL) if (git_index_file == NULL)
strcpy(path_aux + path_len, GIT_INDEX_FILE); strcpy(repo->path_repository + git_dir_path_len, GIT_INDEX_FILE);
else else {
strcpy(path_aux, git_index_file); error = git_prettify_file_path(path_aux, git_index_file);
if (error < GIT_SUCCESS)
return error;
}
if (gitfo_exists(path_aux) < 0) if (gitfo_exists(path_aux) < 0)
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
...@@ -141,9 +147,13 @@ static int assign_repository_DIRs(git_repository *repo, ...@@ -141,9 +147,13 @@ static int assign_repository_DIRs(git_repository *repo,
/* store GIT_WORK_TREE */ /* store GIT_WORK_TREE */
if (git_work_tree == NULL) if (git_work_tree == NULL)
repo->is_bare = 1; repo->is_bare = 1;
else else {
repo->path_workdir = git__strdup(git_work_tree); error = git_prettify_dir_path(path_aux, git_work_tree);
if (error < GIT_SUCCESS)
return error;
repo->path_workdir = git__strdup(path_aux);
}
return GIT_SUCCESS; return GIT_SUCCESS;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment