commit - 6c685612338950f89dc47cd0ef36bcd65fe6404f
commit + 7f4e5320512ed5a2b28d740e0dc25cde52ba1876
blob - 622c0ce1ca669ed14ca0d26259483e9beea95863
blob + 9d45bcc89fba03349491b41c260b4fc0c9606531
--- lib/worktree.c
+++ lib/worktree.c
int delete_local_mods;
int keep_on_disk;
int ignore_missing_paths;
+ const char *status_path;
+ size_t status_path_len;
const char *status_codes;
};
root_len = strlen(a->worktree->root_path);
do {
char *parent;
+
err = got_path_dirname(&parent, ondisk_path);
if (err)
goto done;
free(ondisk_path);
ondisk_path = parent;
+ if (got_path_cmp(ondisk_path, a->status_path,
+ strlen(ondisk_path), a->status_path_len) != 0 &&
+ !got_path_is_child(ondisk_path, a->status_path,
+ a->status_path_len))
+ break;
if (rmdir(ondisk_path) == -1) {
if (errno != ENOTEMPTY)
err = got_error_from_errno2("rmdir",
sda.status_codes = status_codes;
TAILQ_FOREACH(pe, paths, entry) {
+ char *ondisk_status_path;
+
+ if (asprintf(&ondisk_status_path, "%s%s%s",
+ got_worktree_get_root_path(worktree),
+ pe->path[0] == '\0' ? "" : "/", pe->path) == -1) {
+ err = got_error_from_errno("asprintf");
+ goto done;
+ }
+ sda.status_path = ondisk_status_path;
+ sda.status_path_len = strlen(ondisk_status_path);
err = worktree_status(worktree, pe->path, fileindex, repo,
schedule_for_deletion, &sda, NULL, NULL, 1, 1);
+ free(ondisk_status_path);
if (err)
break;
}
struct got_worktree *worktree, struct got_fileindex *fileindex,
got_worktree_delete_cb progress_cb, void *progress_arg)
{
+ const struct got_error *err;
struct schedule_deletion_args sda;
+ char *ondisk_status_path;
memset(&sda, 0, sizeof(sda));
sda.worktree = worktree;
sda.keep_on_disk = 0;
sda.ignore_missing_paths = 0;
sda.status_codes = NULL;
-
- return worktree_status(worktree, path, fileindex, repo,
+ if (asprintf(&ondisk_status_path, "%s/%s",
+ got_worktree_get_root_path(worktree), path) == -1)
+ return got_error_from_errno("asprintf");
+ sda.status_path = ondisk_status_path;
+ sda.status_path_len = strlen(ondisk_status_path);
+
+ err = worktree_status(worktree, path, fileindex, repo,
schedule_for_deletion, &sda, NULL, NULL, 1, 1);
+ free(ondisk_status_path);
+ return err;
}
const struct got_error *