Skip to content

Commit 848c779

Browse files
committed
worktree: Demonstrate missing worktree check
worktree_dir isn't validated when it should be
1 parent 52294c4 commit 848c779

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/worktree/worktree.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,3 +610,17 @@ void test_worktree_worktree__foreach_worktree_lists_all_worktrees(void)
610610
int counter = 0;
611611
cl_git_pass(git_repository_foreach_worktree(fixture.repo, foreach_worktree_cb, &counter));
612612
}
613+
614+
void test_worktree_worktree__validate_invalid_worktreedir(void)
615+
{
616+
git_worktree *wt;
617+
618+
cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree"));
619+
git__free(wt->worktree_path);
620+
wt->worktree_path = "/path/to/invalid/worktreedir";
621+
622+
cl_git_fail(git_worktree_validate(wt));
623+
624+
wt->worktree_path = NULL;
625+
git_worktree_free(wt);
626+
}

0 commit comments

Comments
 (0)