diff options
author | Edward Thomson <ethomson@microsoft.com> | 2015-09-17 16:42:05 +0300 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2015-09-17 17:11:56 +0300 |
commit | e24c60dba4cd7c6b768fd6c39d4a0c003a48fb1f (patch) | |
tree | de04ed1901a455f49ef00d373f1915cf300425db /tests/core | |
parent | 0862ec2eb9529573ab46f3975defc0b7632bede4 (diff) |
mkdir: find component paths for mkdir_relative
`git_futils_mkdir` does not blindly call `git_futils_mkdir_relative`.
`git_futils_mkdir_relative` is used when you have some base directory
and want to create some path inside of it, potentially removing blocking
symlinks and files in the process. This is not suitable for a general
recursive mkdir within the filesystem.
Instead, when `mkdir` is being recursive, locate the first existent
parent directory and use that as the base for `mkdir_relative`.
Diffstat (limited to 'tests/core')
-rw-r--r-- | tests/core/mkdir.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/tests/core/mkdir.c b/tests/core/mkdir.c index 8d487e594..5e6a06002 100644 --- a/tests/core/mkdir.c +++ b/tests/core/mkdir.c @@ -27,25 +27,27 @@ void test_core_mkdir__absolute(void) cl_assert(git_path_isdir(path.ptr)); git_buf_joinpath(&path, path.ptr, "subdir"); - - /* make a directory */ cl_assert(!git_path_isdir(path.ptr)); cl_git_pass(git_futils_mkdir(path.ptr, 0755, 0)); cl_assert(git_path_isdir(path.ptr)); + /* ensure mkdir_r works for a single subdir */ git_buf_joinpath(&path, path.ptr, "another"); - - /* make a directory */ cl_assert(!git_path_isdir(path.ptr)); cl_git_pass(git_futils_mkdir_r(path.ptr, 0755)); cl_assert(git_path_isdir(path.ptr)); + /* ensure mkdir_r works */ git_buf_joinpath(&path, clar_sandbox_path(), "d1/foo/bar/asdf"); - - /* make a directory */ cl_assert(!git_path_isdir(path.ptr)); cl_git_pass(git_futils_mkdir_r(path.ptr, 0755)); cl_assert(git_path_isdir(path.ptr)); + + /* ensure we don't imply recursive */ + git_buf_joinpath(&path, clar_sandbox_path(), "d2/foo/bar/asdf"); + cl_assert(!git_path_isdir(path.ptr)); + cl_git_fail(git_futils_mkdir(path.ptr, 0755, 0)); + cl_assert(!git_path_isdir(path.ptr)); } void test_core_mkdir__basic(void) @@ -285,4 +287,3 @@ void test_core_mkdir__mkdir_path_inside_unwriteable_parent(void) cl_must_pass(p_chmod("r/mode", 0777)); } - |