summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libgit2/worktree.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libgit2/worktree.c b/src/libgit2/worktree.c
index 82e1d2d7e..a8460380f 100644
--- a/src/libgit2/worktree.c
+++ b/src/libgit2/worktree.c
@@ -565,6 +565,7 @@ int git_worktree_is_prunable(git_worktree *wt,
git_worktree_prune_options *opts)
{
git_worktree_prune_options popts = GIT_WORKTREE_PRUNE_OPTIONS_INIT;
+ git_buf path = GIT_BUF_INIT;
GIT_ERROR_CHECK_VERSION(
opts, GIT_WORKTREE_PRUNE_OPTIONS_VERSION,
@@ -595,6 +596,14 @@ int git_worktree_is_prunable(git_worktree *wt,
return 0;
}
+ if (git_buf_printf(&path, "%s/worktrees/%s", wt->commondir_path, wt->name) < 0)
+ return 0;
+ if (!git_path_exists(path.ptr))
+ {
+ git_error_set(GIT_ERROR_WORKTREE, "worktree gitdir '%s' does not exist", path.ptr);
+ return 0;
+ }
+
return 1;
}