summaryrefslogtreecommitdiff
path: root/src/fileops.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-10-17 14:14:51 -0700
committerRussell Belfer <rb@github.com>2012-10-17 14:14:51 -0700
commit4c47a8bcfe03c42096b74d4af06ab95fb95fd211 (patch)
treec79eb8290ef110faff68ae2d5746455095508e1e /src/fileops.c
parent6012e86839bbdfc98085662c22f8e34b6f6abefb (diff)
parent52a61bb8047f431bf363bd9327d0f34884437c83 (diff)
downloadlibgit2-4c47a8bcfe03c42096b74d4af06ab95fb95fd211.tar.gz
Merge pull request #968 from arrbee/diff-support-typechange
Support TYPECHANGE records in status and adjust checkout accordingly
Diffstat (limited to 'src/fileops.c')
-rw-r--r--src/fileops.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/fileops.c b/src/fileops.c
index 6abab8836..3f9e987f0 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -326,10 +326,6 @@ static int _rmdir_recurs_foreach(void *opaque, git_buf *path)
{
git_directory_removal_type removal_type = *(git_directory_removal_type *)opaque;
- assert(removal_type == GIT_DIRREMOVAL_EMPTY_HIERARCHY
- || removal_type == GIT_DIRREMOVAL_FILES_AND_DIRS
- || removal_type == GIT_DIRREMOVAL_ONLY_EMPTY_DIRS);
-
if (git_path_isdir(path->ptr) == true) {
if (git_path_direach(path, _rmdir_recurs_foreach, opaque) < 0)
return -1;
@@ -362,15 +358,24 @@ static int _rmdir_recurs_foreach(void *opaque, git_buf *path)
return 0;
}
-int git_futils_rmdir_r(const char *path, git_directory_removal_type removal_type)
+int git_futils_rmdir_r(
+ const char *path, const char *base, git_directory_removal_type removal_type)
{
int error;
- git_buf p = GIT_BUF_INIT;
+ git_buf fullpath = GIT_BUF_INIT;
+
+ assert(removal_type == GIT_DIRREMOVAL_EMPTY_HIERARCHY
+ || removal_type == GIT_DIRREMOVAL_FILES_AND_DIRS
+ || removal_type == GIT_DIRREMOVAL_ONLY_EMPTY_DIRS);
+
+ /* build path and find "root" where we should start calling mkdir */
+ if (git_path_join_unrooted(&fullpath, path, base, NULL) < 0)
+ return -1;
+
+ error = _rmdir_recurs_foreach(&removal_type, &fullpath);
+
+ git_buf_free(&fullpath);
- error = git_buf_sets(&p, path);
- if (!error)
- error = _rmdir_recurs_foreach(&removal_type, &p);
- git_buf_free(&p);
return error;
}