]> git.proxmox.com Git - libgit2.git/blame - tests/threads/iterator.c
Merge pull request #3399 from arthurschreiber/patch-8
[libgit2.git] / tests / threads / iterator.c
CommitLineData
7d490872
RB
1#include "clar_libgit2.h"
2#include "thread_helpers.h"
3#include "iterator.h"
4
5static git_repository *_repo;
6
7void test_threads_iterator__cleanup(void)
8{
9 cl_git_sandbox_cleanup();
10}
11
12static void *run_workdir_iterator(void *arg)
13{
83038272 14 int error = 0;
7d490872
RB
15 git_iterator *iter;
16 const git_index_entry *entry = NULL;
17
18 cl_git_pass(git_iterator_for_workdir(
62a617dc 19 &iter, _repo, NULL, NULL, GIT_ITERATOR_DONT_AUTOEXPAND, NULL, NULL));
7d490872
RB
20
21 while (!error) {
22 if (entry && entry->mode == GIT_FILEMODE_TREE) {
23 error = git_iterator_advance_into(&entry, iter);
24
25 if (error == GIT_ENOTFOUND)
26 error = git_iterator_advance(&entry, iter);
27 } else {
28 error = git_iterator_advance(&entry, iter);
29 }
30
31 if (!error)
32 (void)git_iterator_current_is_ignored(iter);
33 }
34
35 cl_assert_equal_i(GIT_ITEROVER, error);
36
37 git_iterator_free(iter);
83038272 38 giterr_clear();
7d490872
RB
39 return arg;
40}
41
42
43void test_threads_iterator__workdir(void)
44{
45 _repo = cl_git_sandbox_init("status");
46
47 run_in_parallel(
48 1, 20, run_workdir_iterator, NULL, NULL);
49}