libgit2
libgit2 copied to clipboard
git_worktree_lookup returns GIT_ERROR instead of GIT_ENOTFOUND for a non-existing worktree
Reproduction steps
Call git_worktree_lookup
with a name that does not match the internal name of any existing worktree.
Expected behavior
An error code of GIT_ENOTFOUND
should be returned.
Actual behavior
An error code of GIT_ERROR
is returned instead.
Version of libgit2 (release number or SHA1)
Current main (22f382539d78f69aa91721ad62bbd7229750a043 at time of writing).
Operating system(s) tested
macOS but should happen on any OS.
Likely cause: this line should return GIT_ENOTFOUND
instead of -1 (the code for GIT_ERROR
): https://github.com/libgit2/libgit2/blob/main/src/libgit2/worktree.c#L136
Fixed using https://github.com/libgit2/libgit2/pull/6395.