]> git.proxmox.com Git - libgit2.git/blame - tests/libgit2/threads/iterator.c
Merge https://salsa.debian.org/debian/libgit2 into proxmox/bullseye
[libgit2.git] / tests / libgit2 / 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;
ac3d33df 15 git_repository *repo;
7d490872 16 git_iterator *iter;
ed1c6446 17 git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
7d490872
RB
18 const git_index_entry *entry = NULL;
19
ed1c6446
ET
20 iter_opts.flags = GIT_ITERATOR_DONT_AUTOEXPAND;
21
ac3d33df 22 cl_git_pass(git_repository_open(&repo, git_repository_path(_repo)));
7d490872 23 cl_git_pass(git_iterator_for_workdir(
ac3d33df 24 &iter, repo, NULL, NULL, &iter_opts));
7d490872
RB
25
26 while (!error) {
27 if (entry && entry->mode == GIT_FILEMODE_TREE) {
28 error = git_iterator_advance_into(&entry, iter);
29
30 if (error == GIT_ENOTFOUND)
31 error = git_iterator_advance(&entry, iter);
32 } else {
33 error = git_iterator_advance(&entry, iter);
34 }
35
36 if (!error)
37 (void)git_iterator_current_is_ignored(iter);
38 }
39
40 cl_assert_equal_i(GIT_ITEROVER, error);
41
42 git_iterator_free(iter);
ac3d33df
JK
43 git_repository_free(repo);
44 git_error_clear();
7d490872
RB
45 return arg;
46}
47
48
49void test_threads_iterator__workdir(void)
50{
51 _repo = cl_git_sandbox_init("status");
52
53 run_in_parallel(
54 1, 20, run_workdir_iterator, NULL, NULL);
55}