vendor/libgit2/src/fileops.c in rugged-0.21.4 vs vendor/libgit2/src/fileops.c in rugged-0.22.0b1
- old
+ new
@@ -353,12 +353,13 @@
/* make directory */
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;
}
@@ -372,11 +373,12 @@
/* chmod if requested and necessary */
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;
}
}
@@ -501,26 +503,26 @@
error = futils__error_cannot_rmdir(path->ptr, "still present");
return error;
}
-static int futils__rmdir_empty_parent(void *opaque, git_buf *path)
+static int futils__rmdir_empty_parent(void *opaque, const char *path)
{
futils__rmdir_data *data = opaque;
int error = 0;
- if (git_buf_len(path) <= data->baselen)
+ if (strlen(path) <= data->baselen)
error = GIT_ITEROVER;
- else if (p_rmdir(git_buf_cstr(path)) < 0) {
+ else if (p_rmdir(path) < 0) {
int en = errno;
if (en == ENOENT || en == ENOTDIR) {
/* do nothing */
} else if (en == ENOTEMPTY || en == EEXIST || en == EBUSY) {
error = GIT_ITEROVER;
} else {
- error = git_path_set_error(errno, git_buf_cstr(path), "rmdir");
+ error = git_path_set_error(errno, path, "rmdir");
}
}
return error;
}