diff options
author | Russell Belfer <rb@github.com> | 2012-10-05 15:56:57 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2012-10-09 11:59:34 -0700 |
commit | 0d64bef941928046d114c4da1acb70bd2907855e (patch) | |
tree | 4ae0ac6484c62b0a63ca44f937d67ba15f97d7f0 /src/fileops.c | |
parent | f3a04e0f49d0f46e578613d1c27161abc4c2bf22 (diff) | |
download | libgit2-0d64bef941928046d114c4da1acb70bd2907855e.tar.gz |
Add complex checkout test and then fix checkout
This started as a complex new test for checkout going through the
"typechanges" test repository, but that revealed numerous issues
with checkout, including:
* complete failure with submodules
* failure to create blobs with exec bits
* problems when replacing a tree with a blob because the tree
"example/" sorts after the blob "example" so the delete was
being processed after the single file blob was created
This fixes most of those problems and includes a number of other
minor changes that made it easier to do that, including improving
the TYPECHANGE support in diff/status, etc.
Diffstat (limited to 'src/fileops.c')
-rw-r--r-- | src/fileops.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/fileops.c b/src/fileops.c index 8ccf063d5..23bfa8e55 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -323,10 +323,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; @@ -359,15 +355,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; } |