summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-06-03 13:05:20 -0700
committerRussell Belfer <rb@github.com>2014-06-03 13:05:20 -0700
commitdfcba09e671048668ce55e1efef9f8cf40e4e4a2 (patch)
tree2bb247182abb34577f633c44e66abbc0a2035580 /tests
parentbccb36ebf9d950f7562153d9e9ef9a3678e72516 (diff)
parent2d945f82f63a4df57b2bd9ba6551d99d4517f7f4 (diff)
downloadlibgit2-dfcba09e671048668ce55e1efef9f8cf40e4e4a2.tar.gz
Merge pull request #2395 from libgit2/cmn/ref-iter-concurrent
Concurrent ref iterator access
Diffstat (limited to 'tests')
-rw-r--r--tests/refs/iterator.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/refs/iterator.c b/tests/refs/iterator.c
index a29b0cf8b..c77451309 100644
--- a/tests/refs/iterator.c
+++ b/tests/refs/iterator.c
@@ -186,3 +186,36 @@ void test_refs_iterator__foreach_name_can_cancel(void)
-333);
cl_assert_equal_i(0, cancel_after);
}
+
+void test_refs_iterator__concurrent_delete(void)
+{
+ git_reference_iterator *iter;
+ size_t full_count = 0, concurrent_count = 0;
+ const char *name;
+ int error;
+
+ git_repository_free(repo);
+ repo = cl_git_sandbox_init("testrepo");
+
+ cl_git_pass(git_reference_iterator_new(&iter, repo));
+ while ((error = git_reference_next_name(&name, iter)) == 0) {
+ full_count++;
+ }
+
+ git_reference_iterator_free(iter);
+ cl_assert_equal_i(GIT_ITEROVER, error);
+
+ cl_git_pass(git_reference_iterator_new(&iter, repo));
+ while ((error = git_reference_next_name(&name, iter)) == 0) {
+ cl_git_pass(git_reference_remove(repo, name));
+ concurrent_count++;
+ }
+
+ git_reference_iterator_free(iter);
+ cl_assert_equal_i(GIT_ITEROVER, error);
+
+ cl_assert_equal_i(full_count, concurrent_count);
+
+ cl_git_sandbox_cleanup();
+ repo = NULL;
+}