Skip to content

Commit 86db1ad

Browse files
rbmcleanethomson
authored andcommitted
Added check if gitdir exists in is_prunable()
Fixes libgit2#5598
1 parent 0fd8068 commit 86db1ad

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/libgit2/worktree.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ int git_worktree_is_prunable(git_worktree *wt,
565565
git_worktree_prune_options *opts)
566566
{
567567
git_worktree_prune_options popts = GIT_WORKTREE_PRUNE_OPTIONS_INIT;
568+
git_buf path = GIT_BUF_INIT;
568569

569570
GIT_ERROR_CHECK_VERSION(
570571
opts, GIT_WORKTREE_PRUNE_OPTIONS_VERSION,
@@ -595,6 +596,14 @@ int git_worktree_is_prunable(git_worktree *wt,
595596
return 0;
596597
}
597598

599+
if (git_buf_printf(&path, "%s/worktrees/%s", wt->commondir_path, wt->name) < 0)
600+
return 0;
601+
if (!git_path_exists(path.ptr))
602+
{
603+
git_error_set(GIT_ERROR_WORKTREE, "worktree gitdir '%s' does not exist", path.ptr);
604+
return 0;
605+
}
606+
598607
return 1;
599608
}
600609

0 commit comments

Comments
 (0)