diff options
author | Russell Belfer <rb@github.com> | 2012-12-10 15:31:43 -0800 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-01-04 15:47:42 -0800 |
commit | 7e5c8a5b41ca660def7de23fd32b942878a6ee24 (patch) | |
tree | 477e12bfca0e05c6458ee7bcb25f235ced2714c0 /src/fileops.c | |
parent | cf208031705388a2d1907fb9ec409ff22179f380 (diff) | |
download | libgit2-7e5c8a5b41ca660def7de23fd32b942878a6ee24.tar.gz |
More checkout improvements
This flips checkout back to be driven off the changes between
the baseline and the target trees. This reinstates the complex
code for tracking the contents of the working directory, but
overall, I think the resulting logic is easier to follow.
Diffstat (limited to 'src/fileops.c')
-rw-r--r-- | src/fileops.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/fileops.c b/src/fileops.c index 7f023bf69..47b47d6c8 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -352,6 +352,7 @@ int git_futils_mkdir_r(const char *path, const char *base, const mode_t mode) typedef struct { const char *base; + size_t baselen; uint32_t flags; int error; } futils__rmdir_data; @@ -443,9 +444,13 @@ static int futils__rmdir_recurs_foreach(void *opaque, git_buf *path) static int futils__rmdir_empty_parent(void *opaque, git_buf *path) { - int error = p_rmdir(path->ptr); + futils__rmdir_data *data = opaque; + int error; + + if (git_buf_len(path) <= data->baselen) + return GIT_ITEROVER; - GIT_UNUSED(opaque); + error = p_rmdir(git_buf_cstr(path)); if (error) { int en = errno; @@ -457,7 +462,7 @@ static int futils__rmdir_empty_parent(void *opaque, git_buf *path) giterr_clear(); error = GIT_ITEROVER; } else { - futils__error_cannot_rmdir(path->ptr, NULL); + futils__error_cannot_rmdir(git_buf_cstr(path), NULL); } } @@ -475,9 +480,10 @@ int git_futils_rmdir_r( if (git_path_join_unrooted(&fullpath, path, base, NULL) < 0) return -1; - data.base = base ? base : ""; - data.flags = flags; - data.error = 0; + data.base = base ? base : ""; + data.baselen = base ? strlen(base) : 0; + data.flags = flags; + data.error = 0; error = futils__rmdir_recurs_foreach(&data, &fullpath); |