diff options
author | Russell Belfer <rb@github.com> | 2014-08-22 10:05:09 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2014-08-22 10:05:09 -0700 |
commit | 668ae2ddf854e509dca6e76772b64c9876c1d717 (patch) | |
tree | f16b9f3838a5efb87d7bd70037414b844193f74b /tests | |
parent | d28b2b7a5ff608ce8f3da0e0b6a4c75afcf1e82c (diff) | |
download | libgit2-rb/mkdir-allow-parent-failures.tar.gz |
Allow mkdir helper to skip parent errorsrb/mkdir-allow-parent-failures
Our mkdir helper was failing is a parent directory was not
accessible even if the child directory could be created.
This changes the helper to keep trying child directories
even when the parent is unwritable.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/mkdir.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/core/mkdir.c b/tests/core/mkdir.c index a8c5b10ae..a0e8491a2 100644 --- a/tests/core/mkdir.c +++ b/tests/core/mkdir.c @@ -186,3 +186,34 @@ void test_core_mkdir__chmods(void) cl_git_pass(git_path_lstat("r/mode2/is2/important2.1", &st)); check_mode(0777, st.st_mode); } + +void test_core_mkdir__mkdir_path_inside_unwriteable_parent(void) +{ + struct stat st; + mode_t *old; + + /* FAT filesystems don't support exec bit, nor group/world bits */ + if (!cl_is_chmod_supported()) + return; + + cl_assert((old = git__malloc(sizeof(mode_t))) != NULL); + *old = p_umask(022); + cl_set_cleanup(cleanup_chmod_root, old); + + cl_git_pass(git_futils_mkdir("r", NULL, 0777, 0)); + cl_git_pass(git_futils_mkdir("mode/is/important", "r", 0777, GIT_MKDIR_PATH)); + cl_git_pass(git_path_lstat("r/mode", &st)); + check_mode(0755, st.st_mode); + + cl_must_pass(p_chmod("r/mode", 0111)); + cl_git_pass(git_path_lstat("r/mode", &st)); + check_mode(0111, st.st_mode); + + cl_git_pass( + git_futils_mkdir("mode/is/okay/inside", "r", 0777, GIT_MKDIR_PATH)); + cl_git_pass(git_path_lstat("r/mode/is/okay/inside", &st)); + check_mode(0755, st.st_mode); + + cl_must_pass(p_chmod("r/mode", 0777)); +} + |