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(
GIT_ASSERT_ARG(hint_path || !try_load_filters);
if (!content_path) {
if (git_repository__ensure_not_bare(repo, "create blob from file") < 0)
return GIT_EBAREREPO;
if (git_buf_joinpath(
&path, git_repository_workdir(repo), hint_path) < 0)
if (git_repository_workdir_path(&path, repo, hint_path) < 0)
return -1;
content_path = path.ptr;
......
......@@ -988,7 +988,7 @@ static int index_entry_init(
if (git_repository__ensure_not_bare(repo, "create blob from file") < 0)
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;
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
struct stat st;
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;
if ((error = p_stat(abspath.ptr, &st)) < 0) {
......
......@@ -330,6 +330,10 @@ static int mailmap_add_file_ondisk(
if (error < 0)
goto cleanup;
error = git_path_validate_workdir_buf(repo, &fullpath);
if (error < 0)
goto cleanup;
error = git_futils_readbuffer(&content, fullpath.ptr);
if (error < 0)
goto cleanup;
......
......@@ -98,8 +98,7 @@ static int workdir_reader_read(
git_oid id;
int error;
if ((error = git_buf_joinpath(&path,
git_repository_workdir(reader->repo), filename)) < 0)
if ((error = git_repository_workdir_path(&path, reader->repo, filename)) < 0)
goto done;
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