diff --git a/src/tree.c b/src/tree.c index 4d22f2f63..31a581cdb 100644 --- a/src/tree.c +++ b/src/tree.c @@ -730,7 +730,7 @@ int git_tree_entry_bypath( if (!git_tree_entry__is_tree(entry)) { giterr_set(GITERR_TREE, "The path '%s' does not exist in the given tree", path); - return -1; + return GIT_ENOTFOUND; } /* If there's only a slash left in the path, we diff --git a/tests-clar/object/tree/frompath.c b/tests-clar/object/tree/frompath.c index ef092d1db..fd425517c 100644 --- a/tests-clar/object/tree/frompath.c +++ b/tests-clar/object/tree/frompath.c @@ -46,12 +46,12 @@ void test_object_tree_frompath__retrieve_tree_from_path_to_treeentry(void) assert_tree_from_path(tree, "ab/", "ab"); assert_tree_from_path(tree, "ab/de/", "de"); - cl_must_fail(git_tree_entry_bypath(&e, tree, "i-do-not-exist.txt")); - cl_must_fail(git_tree_entry_bypath(&e, tree, "README/")); - cl_must_fail(git_tree_entry_bypath(&e, tree, "ab/de/fgh/i-do-not-exist.txt")); - cl_must_fail(git_tree_entry_bypath(&e, tree, "nope/de/fgh/1.txt")); - cl_must_fail(git_tree_entry_bypath(&e, tree, "ab/me-neither/fgh/2.txt")); - cl_must_fail(git_tree_entry_bypath(&e, tree, "ab/me-neither/fgh/2.txt/")); + cl_assert_equal_i(GIT_ENOTFOUND, git_tree_entry_bypath(&e, tree, "i-do-not-exist.txt")); + cl_assert_equal_i(GIT_ENOTFOUND, git_tree_entry_bypath(&e, tree, "README/")); + cl_assert_equal_i(GIT_ENOTFOUND, git_tree_entry_bypath(&e, tree, "ab/de/fgh/i-do-not-exist.txt")); + cl_assert_equal_i(GIT_ENOTFOUND, git_tree_entry_bypath(&e, tree, "nope/de/fgh/1.txt")); + cl_assert_equal_i(GIT_ENOTFOUND, git_tree_entry_bypath(&e, tree, "ab/me-neither/fgh/2.txt")); + cl_assert_equal_i(GIT_ENOTFOUND, git_tree_entry_bypath(&e, tree, "ab/me-neither/fgh/2.txt/")); } void test_object_tree_frompath__fail_when_processing_an_invalid_path(void)