summaryrefslogtreecommitdiff
path: root/tests-clar
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2013-11-05 06:05:32 -0800
committerVicent Martí <vicent@github.com>2013-11-05 06:05:32 -0800
commitffd040532a1f3c7f4e268be682bb91fe724693be (patch)
tree4a283f083fe2fe0c0678a6209a19b9a29f2c8f51 /tests-clar
parentb7fbfbb21f4248bf4103a2c13479bf65ba175f36 (diff)
parent1eab9f0e32178a9aac941583c69e1b9cf9849f77 (diff)
downloadlibgit2-ffd040532a1f3c7f4e268be682bb91fe724693be.tar.gz
Merge pull request #1941 from libgit2/rb/preserve-iterator-error
Preserve error messages during file system iterator cleanup
Diffstat (limited to 'tests-clar')
-rw-r--r--tests-clar/repo/iterator.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests-clar/repo/iterator.c b/tests-clar/repo/iterator.c
index 1c513e9e7..56b51852c 100644
--- a/tests-clar/repo/iterator.c
+++ b/tests-clar/repo/iterator.c
@@ -926,3 +926,37 @@ void test_repo_iterator__fs2(void)
expect_iterator_items(i, 12, expect_base, 12, expect_base);
git_iterator_free(i);
}
+
+void test_repo_iterator__fs_preserves_error(void)
+{
+ git_iterator *i;
+ const git_index_entry *e;
+
+ if (!cl_is_chmod_supported())
+ return;
+
+ g_repo = cl_git_sandbox_init("empty_standard_repo");
+
+ cl_must_pass(p_mkdir("empty_standard_repo/r", 0777));
+ cl_git_mkfile("empty_standard_repo/r/a", "hello");
+ cl_must_pass(p_mkdir("empty_standard_repo/r/b", 0777));
+ cl_git_mkfile("empty_standard_repo/r/b/problem", "not me");
+ cl_must_pass(p_chmod("empty_standard_repo/r/b", 0000));
+ cl_must_pass(p_mkdir("empty_standard_repo/r/c", 0777));
+ cl_git_mkfile("empty_standard_repo/r/d", "final");
+
+ cl_git_pass(git_iterator_for_filesystem(
+ &i, "empty_standard_repo/r", 0, NULL, NULL));
+
+ cl_git_pass(git_iterator_advance(&e, i)); /* a */
+ cl_git_fail(git_iterator_advance(&e, i)); /* b */
+ cl_assert(giterr_last());
+ cl_assert(giterr_last()->message != NULL);
+ /* skip 'c/' empty directory */
+ cl_git_pass(git_iterator_advance(&e, i)); /* d */
+ cl_assert_equal_i(GIT_ITEROVER, git_iterator_advance(&e, i));
+
+ cl_must_pass(p_chmod("empty_standard_repo/r/b", 0777));
+
+ git_iterator_free(i);
+}