Skip to content

Commit 2afd018

Browse files
committed
threads::iterator: use separate repository objects
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: libgit2#4753 (comment)
1 parent d191948 commit 2afd018

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/threads/iterator.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@ void test_threads_iterator__cleanup(void)
1212
static void *run_workdir_iterator(void *arg)
1313
{
1414
int error = 0;
15+
git_repository *repo;
1516
git_iterator *iter;
1617
git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
1718
const git_index_entry *entry = NULL;
1819

1920
iter_opts.flags = GIT_ITERATOR_DONT_AUTOEXPAND;
2021

22+
cl_git_pass(git_repository_open(&repo, git_repository_path(_repo)));
2123
cl_git_pass(git_iterator_for_workdir(
22-
&iter, _repo, NULL, NULL, &iter_opts));
24+
&iter, repo, NULL, NULL, &iter_opts));
2325

2426
while (!error) {
2527
if (entry && entry->mode == GIT_FILEMODE_TREE) {
@@ -38,6 +40,7 @@ static void *run_workdir_iterator(void *arg)
3840
cl_assert_equal_i(GIT_ITEROVER, error);
3941

4042
git_iterator_free(iter);
43+
git_repository_free(repo);
4144
giterr_clear();
4245
return arg;
4346
}

0 commit comments

Comments
 (0)