refs: deep unfound ref returns ENOTFOUND

This commit is contained in:
nulltoken 2012-07-07 10:36:35 +02:00
parent 5ffd510dd2
commit d0a920a6fd
2 changed files with 11 additions and 1 deletions

View File

@ -94,7 +94,7 @@ int git_futils_open_ro(const char *path)
{
int fd = p_open(path, O_RDONLY);
if (fd < 0) {
if (errno == ENOENT)
if (errno == ENOENT || errno == ENOTDIR)
fd = GIT_ENOTFOUND;
giterr_set(GITERR_OS, "Failed to open '%s'", path);
}

View File

@ -192,3 +192,13 @@ void test_refs_read__loose_first(void)
git_reference_free(reference);
}
void test_refs_read__unfound_return_ENOTFOUND(void)
{
git_reference *reference;
cl_assert_equal_i(GIT_ENOTFOUND, git_reference_lookup(&reference, g_repo, "test/master"));
cl_assert_equal_i(GIT_ENOTFOUND, git_reference_lookup(&reference, g_repo, "refs/test/master"));
cl_assert_equal_i(GIT_ENOTFOUND, git_reference_lookup(&reference, g_repo, "refs/tags/test/master"));
cl_assert_equal_i(GIT_ENOTFOUND, git_reference_lookup(&reference, g_repo, "refs/tags/test/farther/master"));
}