Commit dc1f4b32d30ce715a58acdd249f15d08ce844233

nulltoken 2012-07-12T10:52:19

tree: unfound tree entry returns GIT_ENOTFOUND

diff --git a/src/tree.c b/src/tree.c
index 4d22f2f..31a581c 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 ef092d1..fd42551 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)