mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-11 13:12:22 +00:00
Made git_repository_open2() and git_repository_open3() benefit from recently added path prettifying function.
This commit is contained in:
parent
618818dcb7
commit
eb2f3b4790
@ -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;
|
||||||
|
|
||||||
|
error = git_prettify_dir_path(path_aux, git_dir);
|
||||||
|
if (error < GIT_SUCCESS)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if (gitfo_isdir(path_aux) < GIT_SUCCESS)
|
||||||
|
return GIT_ENOTFOUND;
|
||||||
|
|
||||||
|
git_dir_path_len = strlen(path_aux);
|
||||||
|
|
||||||
/* store GIT_DIR */
|
/* store GIT_DIR */
|
||||||
path_len = strlen(git_dir);
|
|
||||||
strcpy(path_aux, git_dir);
|
|
||||||
|
|
||||||
if (path_aux[path_len - 1] != '/') {
|
|
||||||
path_aux[path_len] = '/';
|
|
||||||
path_aux[path_len + 1] = 0;
|
|
||||||
|
|
||||||
path_len = path_len + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
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,
|
|||||||
|
|
||||||
/* 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,8 +147,12 @@ 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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user