]>
Commit | Line | Data |
---|---|---|
7d490872 RB |
1 | #include "clar_libgit2.h" |
2 | #include "thread_helpers.h" | |
3 | #include "iterator.h" | |
4 | ||
5 | static git_repository *_repo; | |
6 | ||
7 | void test_threads_iterator__cleanup(void) | |
8 | { | |
9 | cl_git_sandbox_cleanup(); | |
10 | } | |
11 | ||
12 | static 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 | ||
49 | void 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 | } |