summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2018-08-19 12:57:29 +0100
committerEdward Thomson <ethomson@edwardthomson.com>2018-08-19 12:57:29 +0100
commit2afd01857d2f589c694a247072dbce01528edad8 (patch)
tree36436bd84b8386e79fd340e5196754971a20fbb6
parentd1919485a5541fb3171d6fa835c7c0de41243dea (diff)
downloadlibgit2-ethomson/threads.tar.gz
threads::iterator: use separate repository objectsethomson/threads
Our thread policies state that we cannot re-use the `git_repository` across threads. Our tests cannot deviate from that. Courtesy of Ximin Luo, https://github.com/infinity0: https://github.com/libgit2/libgit2/issues/4753#issuecomment-412247757
-rw-r--r--tests/threads/iterator.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/tests/threads/iterator.c b/tests/threads/iterator.c
index 6b86cf1a0..d93c89110 100644
--- a/tests/threads/iterator.c
+++ b/tests/threads/iterator.c
@@ -12,14 +12,16 @@ void test_threads_iterator__cleanup(void)
static void *run_workdir_iterator(void *arg)
{
int error = 0;
+ git_repository *repo;
git_iterator *iter;
git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
const git_index_entry *entry = NULL;
iter_opts.flags = GIT_ITERATOR_DONT_AUTOEXPAND;
+ cl_git_pass(git_repository_open(&repo, git_repository_path(_repo)));
cl_git_pass(git_iterator_for_workdir(
- &iter, _repo, NULL, NULL, &iter_opts));
+ &iter, repo, NULL, NULL, &iter_opts));
while (!error) {
if (entry && entry->mode == GIT_FILEMODE_TREE) {
@@ -38,6 +40,7 @@ static void *run_workdir_iterator(void *arg)
cl_assert_equal_i(GIT_ITEROVER, error);
git_iterator_free(iter);
+ git_repository_free(repo);
giterr_clear();
return arg;
}