diff options
-rw-r--r-- | src/libgit2/worktree.c | 5 | ||||
-rw-r--r-- | tests/libgit2/worktree/worktree.c | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/libgit2/worktree.c b/src/libgit2/worktree.c index 2ac2274f1..82e1d2d7e 100644 --- a/src/libgit2/worktree.c +++ b/src/libgit2/worktree.c @@ -187,6 +187,11 @@ int git_worktree_lookup(git_worktree **out, git_repository *repo, const char *na if ((error = git_str_join3(&path, '/', repo->commondir, "worktrees", name)) < 0) goto out; + if (!git_fs_path_isdir(path.ptr)) { + error = GIT_ENOTFOUND; + goto out; + } + if ((error = (open_worktree_dir(out, git_repository_workdir(repo), path.ptr, name))) < 0) goto out; diff --git a/tests/libgit2/worktree/worktree.c b/tests/libgit2/worktree/worktree.c index 66273d1cb..9fd27f49c 100644 --- a/tests/libgit2/worktree/worktree.c +++ b/tests/libgit2/worktree/worktree.c @@ -120,7 +120,7 @@ void test_worktree_worktree__lookup_nonexistent_worktree(void) { git_worktree *wt; - cl_git_fail(git_worktree_lookup(&wt, fixture.repo, "nonexistent")); + cl_git_fail_with(GIT_ENOTFOUND, git_worktree_lookup(&wt, fixture.repo, "nonexistent")); cl_assert_equal_p(wt, NULL); } |