Commit 578aeba9 by Edward Thomson

use git_repository_workdir_path to generate paths

Use `git_repository_workdir_path` to generate workdir paths since it
will validate the length.
parent 99ddfd5c
...@@ -198,11 +198,7 @@ int git_blob__create_from_paths( ...@@ -198,11 +198,7 @@ int git_blob__create_from_paths(
GIT_ASSERT_ARG(hint_path || !try_load_filters); GIT_ASSERT_ARG(hint_path || !try_load_filters);
if (!content_path) { if (!content_path) {
if (git_repository__ensure_not_bare(repo, "create blob from file") < 0) if (git_repository_workdir_path(&path, repo, hint_path) < 0)
return GIT_EBAREREPO;
if (git_buf_joinpath(
&path, git_repository_workdir(repo), hint_path) < 0)
return -1; return -1;
content_path = path.ptr; content_path = path.ptr;
......
...@@ -988,7 +988,7 @@ static int index_entry_init( ...@@ -988,7 +988,7 @@ static int index_entry_init(
if (git_repository__ensure_not_bare(repo, "create blob from file") < 0) if (git_repository__ensure_not_bare(repo, "create blob from file") < 0)
return GIT_EBAREREPO; return GIT_EBAREREPO;
if (git_buf_joinpath(&path, git_repository_workdir(repo), rel_path) < 0) if (git_repository_workdir_path(&path, repo, rel_path) < 0)
return -1; return -1;
error = git_path_lstat(path.ptr, &st); error = git_path_lstat(path.ptr, &st);
...@@ -1532,7 +1532,7 @@ static int add_repo_as_submodule(git_index_entry **out, git_index *index, const ...@@ -1532,7 +1532,7 @@ static int add_repo_as_submodule(git_index_entry **out, git_index *index, const
struct stat st; struct stat st;
int error; int error;
if ((error = git_buf_joinpath(&abspath, git_repository_workdir(repo), path)) < 0) if ((error = git_repository_workdir_path(&abspath, repo, path)) < 0)
return error; return error;
if ((error = p_stat(abspath.ptr, &st)) < 0) { if ((error = p_stat(abspath.ptr, &st)) < 0) {
......
...@@ -330,6 +330,10 @@ static int mailmap_add_file_ondisk( ...@@ -330,6 +330,10 @@ static int mailmap_add_file_ondisk(
if (error < 0) if (error < 0)
goto cleanup; goto cleanup;
error = git_path_validate_workdir_buf(repo, &fullpath);
if (error < 0)
goto cleanup;
error = git_futils_readbuffer(&content, fullpath.ptr); error = git_futils_readbuffer(&content, fullpath.ptr);
if (error < 0) if (error < 0)
goto cleanup; goto cleanup;
......
...@@ -98,8 +98,7 @@ static int workdir_reader_read( ...@@ -98,8 +98,7 @@ static int workdir_reader_read(
git_oid id; git_oid id;
int error; int error;
if ((error = git_buf_joinpath(&path, if ((error = git_repository_workdir_path(&path, reader->repo, filename)) < 0)
git_repository_workdir(reader->repo), filename)) < 0)
goto done; goto done;
if ((error = p_lstat(path.ptr, &st)) < 0) { if ((error = p_lstat(path.ptr, &st)) < 0) {
......
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