summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/fileops.c2
-rw-r--r--tests-clar/refs/read.c10
2 files changed, 11 insertions, 1 deletions
diff --git a/src/fileops.c b/src/fileops.c
index 95a65893c..5849b79b2 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -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);
}
diff --git a/tests-clar/refs/read.c b/tests-clar/refs/read.c
index d7111b232..6838ead74 100644
--- a/tests-clar/refs/read.c
+++ b/tests-clar/refs/read.c
@@ -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"));
+}