void test_repo_iterator__tree(void) { git_iterator *i; git_iterator_options i_opts = GIT_ITERATOR_OPTIONS_INIT; git_tree *head; g_repo = cl_git_sandbox_init("icase"); cl_git_pass(git_repository_head_tree(&head, g_repo)); /* auto expand with no tree entries */ cl_git_pass(git_iterator_for_tree(&i, head, NULL)); expect_iterator_items(i, 20, NULL, 20, NULL); git_iterator_free(i); /* auto expand with tree entries */ i_opts.flags = GIT_ITERATOR_INCLUDE_TREES; cl_git_pass(git_iterator_for_tree(&i, head, &i_opts)); expect_iterator_items(i, 22, NULL, 22, NULL); git_iterator_free(i); /* no auto expand (implies trees included) */ i_opts.flags = GIT_ITERATOR_DONT_AUTOEXPAND; cl_git_pass(git_iterator_for_tree(&i, head, &i_opts)); expect_iterator_items(i, 12, NULL, 22, NULL); git_iterator_free(i); git_tree_free(head); }
void test_repo_iterator__treefilelist_icase(void) { git_iterator *i; git_iterator_options i_opts = GIT_ITERATOR_OPTIONS_INIT; git_vector filelist; git_tree *tree; cl_git_pass(git_vector_init(&filelist, 100, &git__strcmp_cb)); cl_git_pass(git_vector_insert(&filelist, "a")); cl_git_pass(git_vector_insert(&filelist, "B")); cl_git_pass(git_vector_insert(&filelist, "c")); cl_git_pass(git_vector_insert(&filelist, "D")); cl_git_pass(git_vector_insert(&filelist, "e")); cl_git_pass(git_vector_insert(&filelist, "k.a")); cl_git_pass(git_vector_insert(&filelist, "k.b")); cl_git_pass(git_vector_insert(&filelist, "k/1")); cl_git_pass(git_vector_insert(&filelist, "k/a")); cl_git_pass(git_vector_insert(&filelist, "kZZZZ")); cl_git_pass(git_vector_insert(&filelist, "L/1")); g_repo = cl_git_sandbox_init("icase"); git_repository_head_tree(&tree, g_repo); i_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE; i_opts.pathlist.strings = (char **)filelist.contents; i_opts.pathlist.count = filelist.length; i_opts.start = "c"; i_opts.end = "k/D"; cl_git_pass(git_iterator_for_tree(&i, tree, &i_opts)); expect_iterator_items(i, 3, NULL, 3, NULL); git_iterator_free(i); i_opts.start = "k"; i_opts.end = "k/Z"; cl_git_pass(git_iterator_for_tree(&i, tree, &i_opts)); expect_iterator_items(i, 1, NULL, 1, NULL); git_iterator_free(i); i_opts.flags = GIT_ITERATOR_IGNORE_CASE; i_opts.start = "c"; i_opts.end = "k/D"; cl_git_pass(git_iterator_for_tree(&i, tree, &i_opts)); expect_iterator_items(i, 5, NULL, 5, NULL); git_iterator_free(i); i_opts.start = "k"; i_opts.end = "k/Z"; cl_git_pass(git_iterator_for_tree(&i, tree, &i_opts)); expect_iterator_items(i, 2, NULL, 2, NULL); git_iterator_free(i); git_vector_free(&filelist); git_tree_free(tree); }
void test_repo_iterator__treefilelist(void) { git_iterator *i; git_iterator_options i_opts = GIT_ITERATOR_OPTIONS_INIT; git_vector filelist; git_tree *tree; bool default_icase; int expect; cl_git_pass(git_vector_init(&filelist, 100, &git__strcmp_cb)); cl_git_pass(git_vector_insert(&filelist, "a")); cl_git_pass(git_vector_insert(&filelist, "B")); cl_git_pass(git_vector_insert(&filelist, "c")); cl_git_pass(git_vector_insert(&filelist, "D")); cl_git_pass(git_vector_insert(&filelist, "e")); cl_git_pass(git_vector_insert(&filelist, "k.a")); cl_git_pass(git_vector_insert(&filelist, "k.b")); cl_git_pass(git_vector_insert(&filelist, "k/1")); cl_git_pass(git_vector_insert(&filelist, "k/a")); cl_git_pass(git_vector_insert(&filelist, "kZZZZZZZ")); cl_git_pass(git_vector_insert(&filelist, "L/1")); g_repo = cl_git_sandbox_init("icase"); git_repository_head_tree(&tree, g_repo); /* All indexfilelist iterator tests are "autoexpand with no tree entries" */ /* In this test we DO NOT force a case on the iteratords and verify default behavior. */ i_opts.pathlist.strings = (char **)filelist.contents; i_opts.pathlist.count = filelist.length; cl_git_pass(git_iterator_for_tree(&i, tree, &i_opts)); expect_iterator_items(i, 8, NULL, 8, NULL); git_iterator_free(i); i_opts.start = "c"; i_opts.end = NULL; cl_git_pass(git_iterator_for_tree(&i, tree, &i_opts)); default_icase = git_iterator_ignore_case(i); /* (c D e k/1 k/a L ==> 6) vs (c e k/1 k/a ==> 4) */ expect = ((default_icase) ? 6 : 4); expect_iterator_items(i, expect, NULL, expect, NULL); git_iterator_free(i); i_opts.start = NULL; i_opts.end = "e"; cl_git_pass(git_iterator_for_tree(&i, tree, &i_opts)); default_icase = git_iterator_ignore_case(i); /* (a B c D e ==> 5) vs (B D L/1 a c e ==> 6) */ expect = ((default_icase) ? 5 : 6); expect_iterator_items(i, expect, NULL, expect, NULL); git_iterator_free(i); git_vector_free(&filelist); git_tree_free(tree); }
void test_repo_iterator__tree_case_conflicts_1(void) { const char *blob_sha = "d44e18fb93b7107b5cd1b95d601591d77869a1b6"; git_tree *tree; git_oid blob_id, Ab_id, biga_id, littlea_id, tree_id; git_iterator *i; git_iterator_options i_opts = GIT_ITERATOR_OPTIONS_INIT; const char *expect_cs[] = { "A/a", "A/b/1", "A/c", "a/C", "a/a", "a/b" }; const char *expect_ci[] = { "A/a", "a/b", "A/b/1", "A/c" }; const char *expect_cs_trees[] = { "A/", "A/a", "A/b/", "A/b/1", "A/c", "a/", "a/C", "a/a", "a/b" }; const char *expect_ci_trees[] = { "A/", "A/a", "a/b", "A/b/", "A/b/1", "A/c" }; g_repo = cl_git_sandbox_init("icase"); cl_git_pass(git_oid_fromstr(&blob_id, blob_sha)); /* lookup blob */ /* create: A/a A/b/1 A/c a/a a/b a/C */ build_test_tree(&Ab_id, g_repo, "b|1|", &blob_id); build_test_tree( &biga_id, g_repo, "b|a|,t|b|,b|c|", &blob_id, &Ab_id, &blob_id); build_test_tree( &littlea_id, g_repo, "b|a|,b|b|,b|C|", &blob_id, &blob_id, &blob_id); build_test_tree( &tree_id, g_repo, "t|A|,t|a|", &biga_id, &littlea_id); cl_git_pass(git_tree_lookup(&tree, g_repo, &tree_id)); i_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE; cl_git_pass(git_iterator_for_tree(&i, tree, &i_opts)); expect_iterator_items(i, 6, expect_cs, 6, expect_cs); git_iterator_free(i); i_opts.flags = GIT_ITERATOR_IGNORE_CASE; cl_git_pass(git_iterator_for_tree(&i, tree, &i_opts)); expect_iterator_items(i, 4, expect_ci, 4, expect_ci); git_iterator_free(i); i_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE | GIT_ITERATOR_INCLUDE_TREES; cl_git_pass(git_iterator_for_tree(&i, tree, &i_opts)); expect_iterator_items(i, 9, expect_cs_trees, 9, expect_cs_trees); git_iterator_free(i); i_opts.flags = GIT_ITERATOR_IGNORE_CASE | GIT_ITERATOR_INCLUDE_TREES; cl_git_pass(git_iterator_for_tree(&i, tree, &i_opts)); expect_iterator_items(i, 6, expect_ci_trees, 6, expect_ci_trees); git_iterator_free(i); git_tree_free(tree); }
void test_repo_iterator__tree_case_conflicts_0(void) { const char *blob_sha = "d44e18fb93b7107b5cd1b95d601591d77869a1b6"; git_tree *tree; git_oid blob_id, biga_id, littlea_id, tree_id; git_iterator *i; git_iterator_options i_opts = GIT_ITERATOR_OPTIONS_INIT; const char *expect_cs[] = { "A/1.file", "A/3.file", "a/2.file", "a/4.file" }; const char *expect_ci[] = { "A/1.file", "a/2.file", "A/3.file", "a/4.file" }; const char *expect_cs_trees[] = { "A/", "A/1.file", "A/3.file", "a/", "a/2.file", "a/4.file" }; const char *expect_ci_trees[] = { "A/", "A/1.file", "a/2.file", "A/3.file", "a/4.file" }; g_repo = cl_git_sandbox_init("icase"); cl_git_pass(git_oid_fromstr(&blob_id, blob_sha)); /* lookup blob */ /* create tree with: A/1.file, A/3.file, a/2.file, a/4.file */ build_test_tree( &biga_id, g_repo, "b|1.file|,b|3.file|", &blob_id, &blob_id); build_test_tree( &littlea_id, g_repo, "b|2.file|,b|4.file|", &blob_id, &blob_id); build_test_tree( &tree_id, g_repo, "t|A|,t|a|", &biga_id, &littlea_id); cl_git_pass(git_tree_lookup(&tree, g_repo, &tree_id)); i_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE; cl_git_pass(git_iterator_for_tree(&i, tree, &i_opts)); expect_iterator_items(i, 4, expect_cs, 4, expect_cs); git_iterator_free(i); i_opts.flags = GIT_ITERATOR_IGNORE_CASE; cl_git_pass(git_iterator_for_tree(&i, tree, &i_opts)); expect_iterator_items(i, 4, expect_ci, 4, expect_ci); git_iterator_free(i); i_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE | GIT_ITERATOR_INCLUDE_TREES; cl_git_pass(git_iterator_for_tree(&i, tree, &i_opts)); expect_iterator_items(i, 6, expect_cs_trees, 6, expect_cs_trees); git_iterator_free(i); i_opts.flags = GIT_ITERATOR_IGNORE_CASE | GIT_ITERATOR_INCLUDE_TREES; cl_git_pass(git_iterator_for_tree(&i, tree, &i_opts)); expect_iterator_items(i, 5, expect_ci_trees, 5, expect_ci_trees); git_iterator_free(i); git_tree_free(tree); }
static void check_tree_range( git_repository *repo, const char *start, const char *end, bool ignore_case, int expected_count) { git_tree *head; git_iterator *i; git_iterator_options i_opts = GIT_ITERATOR_OPTIONS_INIT; int error, count; i_opts.flags = ignore_case ? GIT_ITERATOR_IGNORE_CASE : GIT_ITERATOR_DONT_IGNORE_CASE; i_opts.start = start; i_opts.end = end; cl_git_pass(git_repository_head_tree(&head, repo)); cl_git_pass(git_iterator_for_tree(&i, head, &i_opts)); for (count = 0; !(error = git_iterator_advance(NULL, i)); ++count) /* count em up */; cl_assert_equal_i(GIT_ITEROVER, error); cl_assert_equal_i(expected_count, count); git_iterator_free(i); git_tree_free(head); }
int git_note_foreach( git_repository *repo, const char *notes_ref, git_note_foreach_cb note_cb, void *payload) { int error; git_iterator *iter = NULL; git_tree *tree = NULL; git_commit *commit = NULL; const git_index_entry *item; if (!(error = retrieve_note_tree_and_commit( &tree, &commit, repo, ¬es_ref)) && !(error = git_iterator_for_tree(&iter, tree))) error = git_iterator_current(iter, &item); while (!error && item) { error = process_entry_path(item->path, &item->oid, note_cb, payload); if (!error) error = git_iterator_advance(iter, &item); } git_iterator_free(iter); git_tree_free(tree); git_commit_free(commit); return error; }
void test_diff_iterator__tree_special_functions(void) { git_tree *t; git_iterator *i; git_iterator_options i_opts = GIT_ITERATOR_OPTIONS_INIT; const git_index_entry *entry; git_repository *repo = cl_git_sandbox_init("attr"); int error, cases = 0; const char *rootoid = "ce39a97a7fb1fa90bcf5e711249c1e507476ae0e"; t = resolve_commit_oid_to_tree( repo, "24fa9a9fc4e202313e24b648087495441dab432b"); cl_assert(t != NULL); i_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE; cl_git_pass(git_iterator_for_tree(&i, t, &i_opts)); while (!(error = git_iterator_advance(&entry, i))) { cl_assert(entry); if (strcmp(entry->path, "sub/file") == 0) { cases++; check_tree_entry( i, "45b983be36b73c0788dc9cbcb76cbb80fc7bb057", "ecb97df2a174987475ac816e3847fc8e9f6c596b", rootoid, NULL); } else if (strcmp(entry->path, "sub/sub/subsub.txt") == 0) { cases++; check_tree_entry( i, "9e5bdc47d6a80f2be0ea3049ad74231b94609242", "4e49ba8c5b6c32ff28cd9dcb60be34df50fcc485", "ecb97df2a174987475ac816e3847fc8e9f6c596b", rootoid); } else if (strcmp(entry->path, "subdir/.gitattributes") == 0) { cases++; check_tree_entry( i, "99eae476896f4907224978b88e5ecaa6c5bb67a9", "9fb40b6675dde60b5697afceae91b66d908c02d9", rootoid, NULL); } else if (strcmp(entry->path, "subdir2/subdir2_test1") == 0) { cases++; check_tree_entry( i, "dccada462d3df8ac6de596fb8c896aba9344f941", "2929de282ce999e95183aedac6451d3384559c4b", rootoid, NULL); } } cl_assert_equal_i(GIT_ITEROVER, error); cl_assert(!entry); cl_assert_equal_i(4, cases); git_iterator_free(i); git_tree_free(t); }
static void tree_iterator_test( const char *sandbox, const char *treeish, const char *start, const char *end, int expected_count, const char **expected_values) { git_tree *t; git_iterator *i; git_iterator_options i_opts = GIT_ITERATOR_OPTIONS_INIT; const git_index_entry *entry; int error, count = 0, count_post_reset = 0; git_repository *repo = cl_git_sandbox_init(sandbox); i_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE; i_opts.start = start; i_opts.end = end; cl_assert(t = resolve_commit_oid_to_tree(repo, treeish)); cl_git_pass(git_iterator_for_tree(&i, t, &i_opts)); /* test loop */ while (!(error = git_iterator_advance(&entry, i))) { cl_assert(entry); if (expected_values != NULL) cl_assert_equal_s(expected_values[count], entry->path); count++; } cl_assert_equal_i(GIT_ITEROVER, error); cl_assert(!entry); cl_assert_equal_i(expected_count, count); /* test reset */ cl_git_pass(git_iterator_reset(i, NULL, NULL)); while (!(error = git_iterator_advance(&entry, i))) { cl_assert(entry); if (expected_values != NULL) cl_assert_equal_s(expected_values[count_post_reset], entry->path); count_post_reset++; } cl_assert_equal_i(GIT_ITEROVER, error); cl_assert(!entry); cl_assert_equal_i(count, count_post_reset); git_iterator_free(i); git_tree_free(t); }
int git_note_iterator_new( git_note_iterator **it, git_repository *repo, const char *notes_ref) { int error; git_commit *commit = NULL; git_tree *tree = NULL; error = retrieve_note_tree_and_commit(&tree, &commit, repo, ¬es_ref); if (error < 0) goto cleanup; if ((error = git_iterator_for_tree(it, tree, 0, NULL, NULL)) < 0) git_iterator_free(*it); cleanup: git_tree_free(tree); git_commit_free(commit); return error; }
static int submodules_from_head(git_strmap *map, git_tree *head) { int error; git_iterator *i; const git_index_entry *entry; if ((error = git_iterator_for_tree(&i, head, 0, NULL, NULL)) < 0) return error; while (!(error = git_iterator_advance(&entry, i))) { khiter_t pos = git_strmap_lookup_index(map, entry->path); git_submodule *sm; if (git_strmap_valid_index(map, pos)) { sm = git_strmap_value_at(map, pos); if (S_ISGITLINK(entry->mode)) submodule_update_from_head_data(sm, entry->mode, &entry->id); else sm->flags |= GIT_SUBMODULE_STATUS__HEAD_NOT_SUBMODULE; } else if (S_ISGITLINK(entry->mode)) { if (!submodule_get_or_create(&sm, git_tree_owner(head), map, entry->path)) { submodule_update_from_head_data( sm, entry->mode, &entry->id); git_submodule_free(sm); } } } if (error == GIT_ITEROVER) error = 0; git_iterator_free(i); return error; }
void test_repo_iterator__tree_case_conflicts_2(void) { const char *blob_sha = "d44e18fb93b7107b5cd1b95d601591d77869a1b6"; git_tree *tree; git_oid blob_id, d1, d2, c1, c2, b1, b2, a1, a2, tree_id; git_iterator *i; git_iterator_options i_opts = GIT_ITERATOR_OPTIONS_INIT; const char *expect_cs[] = { "A/B/C/D/16", "A/B/C/D/foo", "A/B/C/d/15", "A/B/C/d/FOO", "A/B/c/D/14", "A/B/c/D/foo", "A/B/c/d/13", "A/B/c/d/FOO", "A/b/C/D/12", "A/b/C/D/foo", "A/b/C/d/11", "A/b/C/d/FOO", "A/b/c/D/10", "A/b/c/D/foo", "A/b/c/d/09", "A/b/c/d/FOO", "a/B/C/D/08", "a/B/C/D/foo", "a/B/C/d/07", "a/B/C/d/FOO", "a/B/c/D/06", "a/B/c/D/foo", "a/B/c/d/05", "a/B/c/d/FOO", "a/b/C/D/04", "a/b/C/D/foo", "a/b/C/d/03", "a/b/C/d/FOO", "a/b/c/D/02", "a/b/c/D/foo", "a/b/c/d/01", "a/b/c/d/FOO", }; const char *expect_ci[] = { "a/b/c/d/01", "a/b/c/D/02", "a/b/C/d/03", "a/b/C/D/04", "a/B/c/d/05", "a/B/c/D/06", "a/B/C/d/07", "a/B/C/D/08", "A/b/c/d/09", "A/b/c/D/10", "A/b/C/d/11", "A/b/C/D/12", "A/B/c/d/13", "A/B/c/D/14", "A/B/C/d/15", "A/B/C/D/16", "A/B/C/D/foo", }; const char *expect_ci_trees[] = { "A/", "A/B/", "A/B/C/", "A/B/C/D/", "a/b/c/d/01", "a/b/c/D/02", "a/b/C/d/03", "a/b/C/D/04", "a/B/c/d/05", "a/B/c/D/06", "a/B/C/d/07", "a/B/C/D/08", "A/b/c/d/09", "A/b/c/D/10", "A/b/C/d/11", "A/b/C/D/12", "A/B/c/d/13", "A/B/c/D/14", "A/B/C/d/15", "A/B/C/D/16", "A/B/C/D/foo", }; g_repo = cl_git_sandbox_init("icase"); cl_git_pass(git_oid_fromstr(&blob_id, blob_sha)); /* lookup blob */ build_test_tree(&d1, g_repo, "b|16|,b|foo|", &blob_id, &blob_id); build_test_tree(&d2, g_repo, "b|15|,b|FOO|", &blob_id, &blob_id); build_test_tree(&c1, g_repo, "t|D|,t|d|", &d1, &d2); build_test_tree(&d1, g_repo, "b|14|,b|foo|", &blob_id, &blob_id); build_test_tree(&d2, g_repo, "b|13|,b|FOO|", &blob_id, &blob_id); build_test_tree(&c2, g_repo, "t|D|,t|d|", &d1, &d2); build_test_tree(&b1, g_repo, "t|C|,t|c|", &c1, &c2); build_test_tree(&d1, g_repo, "b|12|,b|foo|", &blob_id, &blob_id); build_test_tree(&d2, g_repo, "b|11|,b|FOO|", &blob_id, &blob_id); build_test_tree(&c1, g_repo, "t|D|,t|d|", &d1, &d2); build_test_tree(&d1, g_repo, "b|10|,b|foo|", &blob_id, &blob_id); build_test_tree(&d2, g_repo, "b|09|,b|FOO|", &blob_id, &blob_id); build_test_tree(&c2, g_repo, "t|D|,t|d|", &d1, &d2); build_test_tree(&b2, g_repo, "t|C|,t|c|", &c1, &c2); build_test_tree(&a1, g_repo, "t|B|,t|b|", &b1, &b2); build_test_tree(&d1, g_repo, "b|08|,b|foo|", &blob_id, &blob_id); build_test_tree(&d2, g_repo, "b|07|,b|FOO|", &blob_id, &blob_id); build_test_tree(&c1, g_repo, "t|D|,t|d|", &d1, &d2); build_test_tree(&d1, g_repo, "b|06|,b|foo|", &blob_id, &blob_id); build_test_tree(&d2, g_repo, "b|05|,b|FOO|", &blob_id, &blob_id); build_test_tree(&c2, g_repo, "t|D|,t|d|", &d1, &d2); build_test_tree(&b1, g_repo, "t|C|,t|c|", &c1, &c2); build_test_tree(&d1, g_repo, "b|04|,b|foo|", &blob_id, &blob_id); build_test_tree(&d2, g_repo, "b|03|,b|FOO|", &blob_id, &blob_id); build_test_tree(&c1, g_repo, "t|D|,t|d|", &d1, &d2); build_test_tree(&d1, g_repo, "b|02|,b|foo|", &blob_id, &blob_id); build_test_tree(&d2, g_repo, "b|01|,b|FOO|", &blob_id, &blob_id); build_test_tree(&c2, g_repo, "t|D|,t|d|", &d1, &d2); build_test_tree(&b2, g_repo, "t|C|,t|c|", &c1, &c2); build_test_tree(&a2, g_repo, "t|B|,t|b|", &b1, &b2); build_test_tree(&tree_id, g_repo, "t/A/,t/a/", &a1, &a2); cl_git_pass(git_tree_lookup(&tree, g_repo, &tree_id)); i_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE; cl_git_pass(git_iterator_for_tree(&i, tree, &i_opts)); expect_iterator_items(i, 32, expect_cs, 32, expect_cs); git_iterator_free(i); i_opts.flags = GIT_ITERATOR_IGNORE_CASE; cl_git_pass(git_iterator_for_tree(&i, tree, &i_opts)); expect_iterator_items(i, 17, expect_ci, 17, expect_ci); git_iterator_free(i); i_opts.flags = GIT_ITERATOR_IGNORE_CASE | GIT_ITERATOR_INCLUDE_TREES; cl_git_pass(git_iterator_for_tree(&i, tree, &i_opts)); expect_iterator_items(i, 21, expect_ci_trees, 21, expect_ci_trees); git_iterator_free(i); git_tree_free(tree); }
void test_repo_iterator__tree_more(void) { git_iterator *i; git_iterator_options i_opts = GIT_ITERATOR_OPTIONS_INIT; git_tree *head; static const char *expect_basic[] = { "current_file", "file_deleted", "modified_file", "staged_changes", "staged_changes_file_deleted", "staged_changes_modified_file", "staged_delete_file_deleted", "staged_delete_modified_file", "subdir.txt", "subdir/current_file", "subdir/deleted_file", "subdir/modified_file", NULL, }; static const char *expect_trees[] = { "current_file", "file_deleted", "modified_file", "staged_changes", "staged_changes_file_deleted", "staged_changes_modified_file", "staged_delete_file_deleted", "staged_delete_modified_file", "subdir.txt", "subdir/", "subdir/current_file", "subdir/deleted_file", "subdir/modified_file", NULL, }; static const char *expect_noauto[] = { "current_file", "file_deleted", "modified_file", "staged_changes", "staged_changes_file_deleted", "staged_changes_modified_file", "staged_delete_file_deleted", "staged_delete_modified_file", "subdir.txt", "subdir/", NULL }; g_repo = cl_git_sandbox_init("status"); cl_git_pass(git_repository_head_tree(&head, g_repo)); /* auto expand with no tree entries */ cl_git_pass(git_iterator_for_tree(&i, head, NULL)); expect_iterator_items(i, 12, expect_basic, 12, expect_basic); git_iterator_free(i); /* auto expand with tree entries */ i_opts.flags = GIT_ITERATOR_INCLUDE_TREES; cl_git_pass(git_iterator_for_tree(&i, head, &i_opts)); expect_iterator_items(i, 13, expect_trees, 13, expect_trees); git_iterator_free(i); /* no auto expand (implies trees included) */ i_opts.flags = GIT_ITERATOR_DONT_AUTOEXPAND; cl_git_pass(git_iterator_for_tree(&i, head, &i_opts)); expect_iterator_items(i, 10, expect_noauto, 13, expect_trees); git_iterator_free(i); git_tree_free(head); }
void test_repo_iterator__tree_icase(void) { git_iterator *i; git_tree *head; git_iterator_options i_opts = GIT_ITERATOR_OPTIONS_INIT; g_repo = cl_git_sandbox_init("icase"); cl_git_pass(git_repository_head_tree(&head, g_repo)); i_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE; /* auto expand with no tree entries */ i_opts.start = "c"; i_opts.end = "k/D"; cl_git_pass(git_iterator_for_tree(&i, head, &i_opts)); expect_iterator_items(i, 7, NULL, 7, NULL); git_iterator_free(i); i_opts.start = "k"; i_opts.end = "k/Z"; cl_git_pass(git_iterator_for_tree(&i, head, &i_opts)); expect_iterator_items(i, 3, NULL, 3, NULL); git_iterator_free(i); i_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE | GIT_ITERATOR_INCLUDE_TREES; /* auto expand with tree entries */ i_opts.start = "c"; i_opts.end = "k/Z"; cl_git_pass(git_iterator_for_tree(&i, head, &i_opts)); expect_iterator_items(i, 8, NULL, 8, NULL); git_iterator_free(i); i_opts.start = "k"; i_opts.end = "k/Z"; cl_git_pass(git_iterator_for_tree(&i, head, &i_opts)); expect_iterator_items(i, 4, NULL, 4, NULL); git_iterator_free(i); /* no auto expand (implies trees included) */ i_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE | GIT_ITERATOR_DONT_AUTOEXPAND; i_opts.start = "c"; i_opts.end = "k/D"; cl_git_pass(git_iterator_for_tree(&i, head, &i_opts)); expect_iterator_items(i, 5, NULL, 8, NULL); git_iterator_free(i); i_opts.start = "k"; i_opts.end = "k/D"; cl_git_pass(git_iterator_for_tree(&i, head, &i_opts)); expect_iterator_items(i, 1, NULL, 4, NULL); git_iterator_free(i); /* auto expand with no tree entries */ i_opts.flags = GIT_ITERATOR_IGNORE_CASE; i_opts.start = "c"; i_opts.end = "k/D"; cl_git_pass(git_iterator_for_tree(&i, head, &i_opts)); expect_iterator_items(i, 13, NULL, 13, NULL); git_iterator_free(i); i_opts.start = "k"; i_opts.end = "k/Z"; cl_git_pass(git_iterator_for_tree(&i, head, &i_opts)); expect_iterator_items(i, 5, NULL, 5, NULL); git_iterator_free(i); /* auto expand with tree entries */ i_opts.flags = GIT_ITERATOR_IGNORE_CASE | GIT_ITERATOR_INCLUDE_TREES; i_opts.start = "c"; i_opts.end = "k/D"; cl_git_pass(git_iterator_for_tree(&i, head, &i_opts)); expect_iterator_items(i, 14, NULL, 14, NULL); git_iterator_free(i); i_opts.start = "k"; i_opts.end = "k/Z"; cl_git_pass(git_iterator_for_tree(&i, head, &i_opts)); expect_iterator_items(i, 6, NULL, 6, NULL); git_iterator_free(i); /* no auto expand (implies trees included) */ i_opts.flags = GIT_ITERATOR_IGNORE_CASE | GIT_ITERATOR_DONT_AUTOEXPAND; i_opts.start = "c"; i_opts.end = "k/D"; cl_git_pass(git_iterator_for_tree(&i, head, &i_opts)); expect_iterator_items(i, 9, NULL, 14, NULL); git_iterator_free(i); i_opts.start = "k"; i_opts.end = "k/Z"; cl_git_pass(git_iterator_for_tree(&i, head, &i_opts)); expect_iterator_items(i, 1, NULL, 6, NULL); git_iterator_free(i); git_tree_free(head); }