summaryrefslogtreecommitdiff
path: root/src/fileops.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-08-22 10:05:09 -0700
committerRussell Belfer <rb@github.com>2014-08-22 10:05:09 -0700
commit668ae2ddf854e509dca6e76772b64c9876c1d717 (patch)
treef16b9f3838a5efb87d7bd70037414b844193f74b /src/fileops.c
parentd28b2b7a5ff608ce8f3da0e0b6a4c75afcf1e82c (diff)
downloadlibgit2-668ae2ddf854e509dca6e76772b64c9876c1d717.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 'src/fileops.c')
-rw-r--r--src/fileops.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/fileops.c b/src/fileops.c
index bebbae4f9..34659ad3b 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -355,8 +355,9 @@ int git_futils_mkdir(
if (p_mkdir(make_path.ptr, mode) < 0) {
int tmp_errno = giterr_system_last();
- /* ignore error if directory already exists */
- if (p_stat(make_path.ptr, &st) < 0 || !S_ISDIR(st.st_mode)) {
+ /* ignore error if not at end or if directory already exists */
+ if (lastch == '\0' &&
+ (p_stat(make_path.ptr, &st) < 0 || !S_ISDIR(st.st_mode))) {
giterr_system_set(tmp_errno);
giterr_set(GITERR_OS, "Failed to make directory '%s'", make_path.ptr);
goto done;
@@ -374,7 +375,8 @@ int git_futils_mkdir(
if (((flags & GIT_MKDIR_CHMOD_PATH) != 0 ||
(lastch == '\0' && (flags & GIT_MKDIR_CHMOD) != 0)) &&
st.st_mode != mode &&
- (error = p_chmod(make_path.ptr, mode)) < 0) {
+ (error = p_chmod(make_path.ptr, mode)) < 0 &&
+ lastch == '\0') {
giterr_set(GITERR_OS, "Failed to set permissions on '%s'", make_path.ptr);
goto done;
}