8000 Merge pull request #6395 from arroz/fix/nonexistent-worktree-lookup-e… · libgit2/libgit2@d78fad1 · GitHub
[go: up one dir, main page]

Skip to content

Commit d78fad1

Browse files
authored
Merge pull request #6395 from arroz/fix/nonexistent-worktree-lookup-error-code
#6366: When a worktree is missing, return GIT_ENOTFOUND.
2 parents 44b8248 + ff0df3a commit d78fad1

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/libgit2/worktree.c

Copy file name to clipboard
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ int git_worktree_lookup(git_worktree **out, git_repository *repo, const char *na
187187
if ((error = git_str_join3(&path, '/', repo->commondir, "worktrees", name)) < 0)
188188
goto out;
189189

190+
if (!git_fs_path_isdir(path.ptr)) {
191+
error = GIT_ENOTFOUND;
192+
goto out;
193+
}
194+
190195
if ((error = (open_worktree_dir(out, git_repository_workdir(repo), path.ptr, name))) < 0)
191196
goto out;
192197

tests/libgit2/worktree/worktree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ void test_worktree_worktree__lookup_nonexistent_worktree(void)
120120
{
121121
git_worktree *wt;
122122

123-
cl_git_fail(git_worktree_lookup(&wt, fixture.repo, "nonexistent"));
123+
cl_git_fail_with(GIT_ENOTFOUND, git_worktree_lookup(&wt, fixture.repo, "nonexistent"));
124124
cl_assert_equal_p(wt, NULL);
125125
}
126126

0 commit comments

Comments
 (0)
0