diff options
| author | Vicent Marti <tanoku@gmail.com> | 2011-02-18 14:11:53 +0200 |
|---|---|---|
| committer | Vicent Marti <tanoku@gmail.com> | 2011-02-18 14:11:53 +0200 |
| commit | 874c3b6f37e291233be389dbacdb7178af85ad2f (patch) | |
| tree | 64c50434044a2f1f0f0b1f2bc5433fa194a83a9a /src | |
| parent | cb77ad0d4e66262393c3fa868a7bc723cfd71d61 (diff) | |
| download | libgit2-874c3b6f37e291233be389dbacdb7178af85ad2f.tar.gz | |
Fix repository initialization
Fixed several issues with path joining and bare repos.
Signed-off-by: Vicent Marti <tanoku@gmail.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/repository.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/repository.c b/src/repository.c index 226e20f51..2b17ba455 100644 --- a/src/repository.c +++ b/src/repository.c @@ -581,7 +581,7 @@ static int repo_init_structure(repo_init *results) strcpy(temp_path, git_dir); /* Does HEAD file already exist ? */ - strcpy(temp_path + path_len, GIT_HEAD_FILE); + git__joinpath(temp_path, git_dir, GIT_HEAD_FILE); if (gitfo_exists(temp_path) == GIT_SUCCESS) return repo_init_reinit(results); @@ -590,22 +590,22 @@ static int repo_init_structure(repo_init *results) return GIT_ERROR; /* Creates the '/objects/info/' directory */ - strcpy(temp_path + path_len, GIT_OBJECTS_INFO_DIR); - if (gitfo_mkdir_recurs(temp_path, mode)) + git__joinpath(temp_path, git_dir, GIT_OBJECTS_INFO_DIR); + if (gitfo_mkdir_recurs(temp_path, mode) < GIT_SUCCESS) return GIT_ERROR; /* Creates the '/objects/pack/' directory */ - strcpy(temp_path + path_len, GIT_OBJECTS_PACK_DIR); + git__joinpath(temp_path, git_dir, GIT_OBJECTS_PACK_DIR); if (gitfo_mkdir(temp_path, mode)) return GIT_ERROR; /* Creates the '/refs/heads/' directory */ - strcpy(temp_path + path_len, GIT_REFS_HEADS_DIR); + git__joinpath(temp_path, git_dir, GIT_REFS_HEADS_DIR); if (gitfo_mkdir_recurs(temp_path, mode)) return GIT_ERROR; /* Creates the '/refs/tags/' directory */ - strcpy(temp_path + path_len, GIT_REFS_TAGS_DIR); + git__joinpath(temp_path, git_dir, GIT_REFS_TAGS_DIR); if (gitfo_mkdir(temp_path, mode)) return GIT_ERROR; @@ -617,23 +617,21 @@ static int repo_init_structure(repo_init *results) static int repo_init_find_dir(repo_init *results, const char* path) { char temp_path[GIT_PATH_MAX]; - int path_len; int error = GIT_SUCCESS; error = gitfo_prettify_dir_path(temp_path, path); if (error < GIT_SUCCESS) return error; - path_len = strlen(temp_path); +/* + if (gitfo_isdir(temp_path) < GIT_SUCCESS) + return GIT_ENOTAREPO; +*/ if (!results->is_bare) { - strcpy(temp_path + path_len - 1, GIT_DIR); - path_len = path_len + strlen(GIT_DIR) - 1; /* Skip the leading slash from the constant */ + git__joinpath(temp_path, temp_path, GIT_DIR); } - if (path_len >= GIT_PATH_MAX - MAX_GITDIR_TREE_STRUCTURE_PATH_LENGTH) - return GIT_ENOTAREPO; - results->path_repository = git__strdup(temp_path); if (results->path_repository == NULL) return GIT_ENOMEM; |
