tree: unfound tree entry returns GIT_ENOTFOUND

This commit is contained in:
nulltoken 2012-07-12 10:52:19 +02:00
parent 1c3edb3078
commit dc1f4b32d3
2 changed files with 7 additions and 7 deletions

View File

@ -730,7 +730,7 @@ int git_tree_entry_bypath(
if (!git_tree_entry__is_tree(entry)) { if (!git_tree_entry__is_tree(entry)) {
giterr_set(GITERR_TREE, giterr_set(GITERR_TREE,
"The path '%s' does not exist in the given tree", path); "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 /* If there's only a slash left in the path, we

View File

@ -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/", "ab");
assert_tree_from_path(tree, "ab/de/", "de"); assert_tree_from_path(tree, "ab/de/", "de");
cl_must_fail(git_tree_entry_bypath(&e, tree, "i-do-not-exist.txt")); cl_assert_equal_i(GIT_ENOTFOUND, git_tree_entry_bypath(&e, tree, "i-do-not-exist.txt"));
cl_must_fail(git_tree_entry_bypath(&e, tree, "README/")); cl_assert_equal_i(GIT_ENOTFOUND, 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_assert_equal_i(GIT_ENOTFOUND, 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_assert_equal_i(GIT_ENOTFOUND, 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_assert_equal_i(GIT_ENOTFOUND, 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, "ab/me-neither/fgh/2.txt/"));
} }
void test_object_tree_frompath__fail_when_processing_an_invalid_path(void) void test_object_tree_frompath__fail_when_processing_an_invalid_path(void)