Unverified Commit d78fad15 by Edward Thomson Committed by GitHub

Merge pull request #6395 from arroz/fix/nonexistent-worktree-lookup-error-code

#6366: When a worktree is missing, return GIT_ENOTFOUND.
parents 44b82485 ff0df3ae
......@@ -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;
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment