]> git.proxmox.com Git - libgit2.git/commitdiff
iterator: use an options struct instead of args
authorEdward Thomson <ethomson@edwardthomson.com>
Tue, 28 Jul 2015 16:41:27 +0000 (11:41 -0500)
committerEdward Thomson <ethomson@microsoft.com>
Fri, 28 Aug 2015 22:39:47 +0000 (18:39 -0400)
16 files changed:
src/checkout.c
src/diff.c
src/index.c
src/iterator.c
src/iterator.h
src/merge.c
src/notes.c
src/pathspec.c
src/refdb_fs.c
src/stash.c
src/submodule.c
tests/diff/iterator.c
tests/merge/trees/treediff.c
tests/repo/iterator.c
tests/submodule/status.c
tests/threads/iterator.c

index 4b3acbcce5982415b1ba174caf264116146235ba..311040d598e06a79db1a01a8d04393c9ff14b161 100644 (file)
@@ -2471,11 +2471,12 @@ int git_checkout_iterator(
 {
        int error = 0;
        git_iterator *baseline = NULL, *workdir = NULL;
+       git_iterator_options baseline_opts = GIT_ITERATOR_OPTIONS_INIT,
+               workdir_opts = GIT_ITERATOR_OPTIONS_INIT;
        checkout_data data = {0};
        git_diff_options diff_opts = GIT_DIFF_OPTIONS_INIT;
        uint32_t *actions = NULL;
        size_t *counts = NULL;
-       git_iterator_flag_t iterflags = 0;
 
        /* initialize structures and options */
        error = checkout_data_init(&data, target, opts);
@@ -2499,25 +2500,30 @@ int git_checkout_iterator(
 
        /* set up iterators */
 
-       iterflags = git_iterator_ignore_case(target) ?
+       workdir_opts.flags = git_iterator_ignore_case(target) ?
                GIT_ITERATOR_IGNORE_CASE : GIT_ITERATOR_DONT_IGNORE_CASE;
+       workdir_opts.flags |= GIT_ITERATOR_DONT_AUTOEXPAND;
+       workdir_opts.start = data.pfx;
+       workdir_opts.end = data.pfx;
 
        if ((error = git_iterator_reset(target, data.pfx, data.pfx)) < 0 ||
                (error = git_iterator_for_workdir_ext(
                        &workdir, data.repo, data.opts.target_directory, index, NULL,
-                       iterflags | GIT_ITERATOR_DONT_AUTOEXPAND,
-                       data.pfx, data.pfx)) < 0)
+                       &workdir_opts)) < 0)
                goto cleanup;
 
+       baseline_opts.flags = git_iterator_ignore_case(target) ?
+               GIT_ITERATOR_IGNORE_CASE : GIT_ITERATOR_DONT_IGNORE_CASE;
+       baseline_opts.start = data.pfx;
+       baseline_opts.end = data.pfx;
+
        if (data.opts.baseline_index) {
                if ((error = git_iterator_for_index(
-                               &baseline, data.opts.baseline_index,
-                               iterflags, data.pfx, data.pfx)) < 0)
+                               &baseline, data.opts.baseline_index, &baseline_opts)) < 0)
                        goto cleanup;
        } else {
                if ((error = git_iterator_for_tree(
-                               &baseline, data.opts.baseline,
-                               iterflags, data.pfx, data.pfx)) < 0)
+                               &baseline, data.opts.baseline, &baseline_opts)) < 0)
                        goto cleanup;
        }
 
@@ -2625,7 +2631,7 @@ int git_checkout_index(
                return error;
        GIT_REFCOUNT_INC(index);
 
-       if (!(error = git_iterator_for_index(&index_i, index, 0, NULL, NULL)))
+       if (!(error = git_iterator_for_index(&index_i, index, NULL)))
                error = git_checkout_iterator(index_i, index, opts);
 
        if (owned)
@@ -2681,7 +2687,7 @@ int git_checkout_tree(
        if ((error = git_repository_index(&index, repo)) < 0)
                return error;
 
-       if (!(error = git_iterator_for_tree(&tree_i, tree, 0, NULL, NULL)))
+       if (!(error = git_iterator_for_tree(&tree_i, tree, NULL)))
                error = git_checkout_iterator(tree_i, index, opts);
 
        git_iterator_free(tree_i);
index 44f62788086f3b9aa0237fbca6052eac06089c24..58004db2105e45f304ab295756bb2a83a89d10fc 100644 (file)
@@ -1264,9 +1264,17 @@ cleanup:
        return error;
 }
 
-#define DIFF_FROM_ITERATORS(MAKE_FIRST, MAKE_SECOND) do { \
+#define DIFF_FROM_ITERATORS(MAKE_FIRST, FLAGS_FIRST, MAKE_SECOND, FLAGS_SECOND) do { \
        git_iterator *a = NULL, *b = NULL; \
        char *pfx = opts ? git_pathspec_prefix(&opts->pathspec) : NULL; \
+       git_iterator_options a_opts = GIT_ITERATOR_OPTIONS_INIT, \
+               b_opts = GIT_ITERATOR_OPTIONS_INIT; \
+       a_opts.flags = FLAGS_FIRST; \
+       a_opts.start = pfx; \
+       a_opts.end = pfx; \
+       b_opts.flags = FLAGS_SECOND; \
+       b_opts.start = pfx; \
+       b_opts.end = pfx; \
        GITERR_CHECK_VERSION(opts, GIT_DIFF_OPTIONS_VERSION, "git_diff_options"); \
        if (!(error = MAKE_FIRST) && !(error = MAKE_SECOND)) \
                error = git_diff__from_iterators(diff, repo, a, b, opts); \
@@ -1280,8 +1288,8 @@ int git_diff_tree_to_tree(
        git_tree *new_tree,
        const git_diff_options *opts)
 {
-       int error = 0;
        git_iterator_flag_t iflag = GIT_ITERATOR_DONT_IGNORE_CASE;
+       int error = 0;
 
        assert(diff && repo);
 
@@ -1293,8 +1301,8 @@ int git_diff_tree_to_tree(
                iflag = GIT_ITERATOR_IGNORE_CASE;
 
        DIFF_FROM_ITERATORS(
-               git_iterator_for_tree(&a, old_tree, iflag, pfx, pfx),
-               git_iterator_for_tree(&b, new_tree, iflag, pfx, pfx)
+               git_iterator_for_tree(&a, old_tree, &a_opts), iflag,
+               git_iterator_for_tree(&b, new_tree, &b_opts), iflag
        );
 
        return error;
@@ -1318,10 +1326,10 @@ int git_diff_tree_to_index(
        git_index *index,
        const git_diff_options *opts)
 {
-       int error = 0;
-       bool index_ignore_case = false;
        git_iterator_flag_t iflag = GIT_ITERATOR_DONT_IGNORE_CASE |
                GIT_ITERATOR_INCLUDE_CONFLICTS;
+       bool index_ignore_case = false;
+       int error = 0;
 
        assert(diff && repo);
 
@@ -1331,8 +1339,8 @@ int git_diff_tree_to_index(
        index_ignore_case = index->ignore_case;
 
        DIFF_FROM_ITERATORS(
-               git_iterator_for_tree(&a, old_tree, iflag, pfx, pfx),
-               git_iterator_for_index(&b, index, iflag, pfx, pfx)
+               git_iterator_for_tree(&a, old_tree, &a_opts), iflag,
+               git_iterator_for_index(&b, index, &b_opts), iflag
        );
 
        /* if index is in case-insensitive order, re-sort deltas to match */
@@ -1356,10 +1364,11 @@ int git_diff_index_to_workdir(
                return error;
 
        DIFF_FROM_ITERATORS(
-               git_iterator_for_index(
-                       &a, index, GIT_ITERATOR_INCLUDE_CONFLICTS, pfx, pfx),
-               git_iterator_for_workdir(
-                       &b, repo, index, NULL, GIT_ITERATOR_DONT_AUTOEXPAND, pfx, pfx)
+               git_iterator_for_index(&a, index, &a_opts),
+               GIT_ITERATOR_INCLUDE_CONFLICTS,
+
+               git_iterator_for_workdir(&b, repo, index, NULL, &b_opts),
+               GIT_ITERATOR_DONT_AUTOEXPAND
        );
 
        if (!error && DIFF_FLAG_IS_SET(*diff, GIT_DIFF_UPDATE_INDEX) && (*diff)->index_updated)
@@ -1383,9 +1392,8 @@ int git_diff_tree_to_workdir(
                return error;
 
        DIFF_FROM_ITERATORS(
-               git_iterator_for_tree(&a, old_tree, 0, pfx, pfx),
-               git_iterator_for_workdir(
-                       &b, repo, index, old_tree, GIT_ITERATOR_DONT_AUTOEXPAND, pfx, pfx)
+               git_iterator_for_tree(&a, old_tree, &a_opts), 0,
+               git_iterator_for_workdir(&b, repo, index, old_tree, &b_opts), GIT_ITERATOR_DONT_AUTOEXPAND
        );
 
        return error;
@@ -1433,10 +1441,8 @@ int git_diff_index_to_index(
        assert(diff && old_index && new_index);
 
        DIFF_FROM_ITERATORS(
-               git_iterator_for_index(
-                       &a, old_index, GIT_ITERATOR_DONT_IGNORE_CASE, pfx, pfx),
-               git_iterator_for_index(
-                       &b, new_index, GIT_ITERATOR_DONT_IGNORE_CASE, pfx, pfx)
+               git_iterator_for_index(&a, old_index, &a_opts), GIT_ITERATOR_DONT_IGNORE_CASE,
+               git_iterator_for_index(&b, new_index, &b_opts), GIT_ITERATOR_DONT_IGNORE_CASE
        );
 
        /* if index is in case-insensitive order, re-sort deltas to match */
index e424698bb96adf8d06a39ebb80c5081d11b2fcb4..a6a62e3270a2e5ef2d1462b466fb866ff240a322 100644 (file)
@@ -2658,6 +2658,7 @@ int git_index_read_index(
                remove_entries = GIT_VECTOR_INIT;
        git_iterator *index_iterator = NULL;
        git_iterator *new_iterator = NULL;
+       git_iterator_options opts = GIT_ITERATOR_OPTIONS_INIT;
        const git_index_entry *old_entry, *new_entry;
        git_index_entry *entry;
        size_t i;
@@ -2667,10 +2668,10 @@ int git_index_read_index(
                (error = git_vector_init(&remove_entries, index->entries.length, NULL)) < 0)
                goto done;
 
-       if ((error = git_iterator_for_index(&index_iterator,
-                       index, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0 ||
-               (error = git_iterator_for_index(&new_iterator,
-                       (git_index *)new_index, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0)
+       opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE;
+
+       if ((error = git_iterator_for_index(&index_iterator, index, &opts)) < 0 ||
+               (error = git_iterator_for_index(&new_iterator, (git_index *)new_index, &opts)) < 0)
                goto done;
 
        if (((error = git_iterator_current(&old_entry, index_iterator)) < 0 && 
index 900ffdcaa8b3ebd89b5dc05fd6c8a26c68df6c92..374caf96d1d03e43b22fa7d13c6719ea935fae37 100644 (file)
        (P)->base.cb      = &(P)->cb; \
        ITERATOR_SET_CB(P,NAME_LC); \
        (P)->base.repo    = (REPO); \
-       (P)->base.start   = start ? git__strdup(start) : NULL; \
-       (P)->base.end     = end ? git__strdup(end) : NULL; \
-       if ((start && !(P)->base.start) || (end && !(P)->base.end)) { \
+       (P)->base.start   = options && options->start ? \
+               git__strdup(options->start) : NULL; \
+       (P)->base.end     = options && options->end ? \
+               git__strdup(options->end) : NULL; \
+       if ((options && options->start && !(P)->base.start) || \
+               (options && options->end && !(P)->base.end)) { \
                git__free(P); return -1; } \
        (P)->base.prefixcomp = git__prefixcmp; \
-       (P)->base.flags = flags & ~ITERATOR_CASE_FLAGS; \
+       (P)->base.flags = options ? options->flags & ~ITERATOR_CASE_FLAGS : 0; \
        if ((P)->base.flags & GIT_ITERATOR_DONT_AUTOEXPAND) \
                (P)->base.flags |= GIT_ITERATOR_INCLUDE_TREES; \
        } while (0)
@@ -149,9 +152,7 @@ typedef struct {
 
 int git_iterator_for_nothing(
        git_iterator **iter,
-       git_iterator_flag_t flags,
-       const char *start,
-       const char *end)
+       git_iterator_options *options)
 {
        empty_iterator *i = git__calloc(1, sizeof(empty_iterator));
        GITERR_CHECK_ALLOC(i);
@@ -162,7 +163,7 @@ int git_iterator_for_nothing(
 
        ITERATOR_BASE_INIT(i, empty, EMPTY, NULL);
 
-       if ((flags & GIT_ITERATOR_IGNORE_CASE) != 0)
+       if (options && (options->flags & GIT_ITERATOR_IGNORE_CASE) != 0)
                i->base.flags |= GIT_ITERATOR_IGNORE_CASE;
 
        *iter = (git_iterator *)i;
@@ -607,15 +608,13 @@ static int tree_iterator__create_root_frame(tree_iterator *ti, git_tree *tree)
 int git_iterator_for_tree(
        git_iterator **iter,
        git_tree *tree,
-       git_iterator_flag_t flags,
-       const char *start,
-       const char *end)
+       git_iterator_options *options)
 {
        int error;
        tree_iterator *ti;
 
        if (tree == NULL)
-               return git_iterator_for_nothing(iter, flags, start, end);
+               return git_iterator_for_nothing(iter, options);
 
        if ((error = git_object_dup((git_object **)&tree, (git_object *)tree)) < 0)
                return error;
@@ -625,7 +624,7 @@ int git_iterator_for_tree(
 
        ITERATOR_BASE_INIT(ti, tree, TREE, git_tree_owner(tree));
 
-       if ((error = iterator__update_ignore_case((git_iterator *)ti, flags)) < 0)
+       if ((error = iterator__update_ignore_case((git_iterator *)ti, options ? options->flags : 0)) < 0)
                goto fail;
        ti->strncomp = iterator__ignore_case(ti) ? git__strncasecmp : git__strncmp;
 
@@ -860,9 +859,7 @@ static void index_iterator__free(git_iterator *self)
 int git_iterator_for_index(
        git_iterator **iter,
        git_index  *index,
-       git_iterator_flag_t flags,
-       const char *start,
-       const char *end)
+       git_iterator_options *options)
 {
        int error = 0;
        index_iterator *ii = git__calloc(1, sizeof(index_iterator));
@@ -876,7 +873,7 @@ int git_iterator_for_index(
 
        ITERATOR_BASE_INIT(ii, index, INDEX, git_index_owner(index));
 
-       if ((error = iterator__update_ignore_case((git_iterator *)ii, flags)) < 0) {
+       if ((error = iterator__update_ignore_case((git_iterator *)ii, options ? options->flags : 0)) < 0) {
                git_iterator_free((git_iterator *)ii);
                return error;
        }
@@ -1062,6 +1059,8 @@ static int dirload_with_stat(
 
                memcpy(ps->path, path, path_len);
 
+               /* TODO: don't stat if assume unchanged for this path */
+
                if ((error = git_path_diriter_stat(&ps->st, &diriter)) < 0) {
                        if (error == GIT_ENOTFOUND) {
                                /* file was removed between readdir and lstat */
@@ -1366,16 +1365,14 @@ static int fs_iterator__initialize(
 int git_iterator_for_filesystem(
        git_iterator **out,
        const char *root,
-       git_iterator_flag_t flags,
-       const char *start,
-       const char *end)
+       git_iterator_options *options)
 {
        fs_iterator *fi = git__calloc(1, sizeof(fs_iterator));
        GITERR_CHECK_ALLOC(fi);
 
        ITERATOR_BASE_INIT(fi, fs, FS, NULL);
 
-       if ((flags & GIT_ITERATOR_IGNORE_CASE) != 0)
+       if (options && (options->flags & GIT_ITERATOR_IGNORE_CASE) != 0)
                fi->base.flags |= GIT_ITERATOR_IGNORE_CASE;
 
        return fs_iterator__initialize(out, fi, root);
@@ -1559,9 +1556,7 @@ int git_iterator_for_workdir_ext(
        const char *repo_workdir,
        git_index *index,
        git_tree *tree,
-       git_iterator_flag_t flags,
-       const char *start,
-       const char *end)
+       git_iterator_options *options)
 {
        int error, precompose = 0;
        workdir_iterator *wi;
@@ -1583,7 +1578,7 @@ int git_iterator_for_workdir_ext(
        wi->fi.leave_dir_cb = workdir_iterator__leave_dir;
        wi->fi.update_entry_cb = workdir_iterator__update_entry;
 
-       if ((error = iterator__update_ignore_case((git_iterator *)wi, flags)) < 0 ||
+       if ((error = iterator__update_ignore_case((git_iterator *)wi, options ? options->flags : 0)) < 0 ||
                (error = git_ignore__for_path(repo, ".gitignore", &wi->ignores)) < 0)
        {
                git_iterator_free((git_iterator *)wi);
index 893e5db5045bef80e9e32ef5e3d6d61edc150352..46e96f0448ad7ad4982324e436a83da203d499d3 100644 (file)
@@ -38,6 +38,17 @@ typedef enum {
        GIT_ITERATOR_INCLUDE_CONFLICTS = (1u << 5),
 } git_iterator_flag_t;
 
+
+typedef struct {
+       const char *start;
+       const char *end;
+
+       /* flags, from above */
+       unsigned int flags;
+} git_iterator_options;
+
+#define GIT_ITERATOR_OPTIONS_INIT {0}
+
 typedef struct {
        int (*current)(const git_index_entry **, git_iterator *);
        int (*advance)(const git_index_entry **, git_iterator *);
@@ -61,9 +72,7 @@ struct git_iterator {
 
 extern int git_iterator_for_nothing(
        git_iterator **out,
-       git_iterator_flag_t flags,
-       const char *start,
-       const char *end);
+       git_iterator_options *options);
 
 /* tree iterators will match the ignore_case value from the index of the
  * repository, unless you override with a non-zero flag value
@@ -71,9 +80,7 @@ extern int git_iterator_for_nothing(
 extern int git_iterator_for_tree(
        git_iterator **out,
        git_tree *tree,
-       git_iterator_flag_t flags,
-       const char *start,
-       const char *end);
+       git_iterator_options *options);
 
 /* index iterators will take the ignore_case value from the index; the
  * ignore_case flags are not used
@@ -81,9 +88,7 @@ extern int git_iterator_for_tree(
 extern int git_iterator_for_index(
        git_iterator **out,
        git_index *index,
-       git_iterator_flag_t flags,
-       const char *start,
-       const char *end);
+       git_iterator_options *options);
 
 extern int git_iterator_for_workdir_ext(
        git_iterator **out,
@@ -91,9 +96,7 @@ extern int git_iterator_for_workdir_ext(
        const char *repo_workdir,
        git_index *index,
        git_tree *tree,
-       git_iterator_flag_t flags,
-       const char *start,
-       const char *end);
+       git_iterator_options *options);
 
 /* workdir iterators will match the ignore_case value from the index of the
  * repository, unless you override with a non-zero flag value
@@ -103,11 +106,9 @@ GIT_INLINE(int) git_iterator_for_workdir(
        git_repository *repo,
        git_index *index,
        git_tree *tree,
-       git_iterator_flag_t flags,
-       const char *start,
-       const char *end)
+       git_iterator_options *options)
 {
-       return git_iterator_for_workdir_ext(out, repo, NULL, index, tree, flags, start, end);
+       return git_iterator_for_workdir_ext(out, repo, NULL, index, tree, options);
 }
 
 /* for filesystem iterators, you have to explicitly pass in the ignore_case
@@ -116,9 +117,7 @@ GIT_INLINE(int) git_iterator_for_workdir(
 extern int git_iterator_for_filesystem(
        git_iterator **out,
        const char *root,
-       git_iterator_flag_t flags,
-       const char *start,
-       const char *end);
+       git_iterator_options *options);
 
 extern void git_iterator_free(git_iterator *iter);
 
index 863ac8f2d11c4b26c497699a454bdac82e1f1ce5..16cd2aee0802d8d26beb2bd70710ee23d7e511c3 100644 (file)
@@ -1695,10 +1695,14 @@ on_error:
 
 static git_iterator *iterator_given_or_empty(git_iterator **empty, git_iterator *given)
 {
+       git_iterator_options opts = GIT_ITERATOR_OPTIONS_INIT;
+
        if (given)
                return given;
 
-       if (git_iterator_for_nothing(empty, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL) < 0)
+       opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE;
+
+       if (git_iterator_for_nothing(empty, &opts) < 0)
                return NULL;
 
        return *empty;
@@ -1780,14 +1784,17 @@ int git_merge_trees(
        const git_merge_options *merge_opts)
 {
        git_iterator *ancestor_iter = NULL, *our_iter = NULL, *their_iter = NULL;
+       git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
        int error;
 
-       if ((error = git_iterator_for_tree(&ancestor_iter, (git_tree *)ancestor_tree,
-                       GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0 ||
-               (error = git_iterator_for_tree(&our_iter, (git_tree *)our_tree,
-                       GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0 ||
-               (error = git_iterator_for_tree(&their_iter, (git_tree *)their_tree,
-                       GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0)
+       iter_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE;
+
+       if ((error = git_iterator_for_tree(
+                       &ancestor_iter, (git_tree *)ancestor_tree, &iter_opts)) < 0 ||
+               (error = git_iterator_for_tree(
+                       &our_iter, (git_tree *)our_tree, &iter_opts)) < 0 ||
+               (error = git_iterator_for_tree(
+                       &their_iter, (git_tree *)their_tree, &iter_opts)) < 0)
                goto done;
 
        error = git_merge__iterators(
@@ -2319,6 +2326,7 @@ static int merge_check_index(size_t *conflicts, git_repository *repo, git_index
        git_tree *head_tree = NULL;
        git_index *index_repo = NULL;
        git_iterator *iter_repo = NULL, *iter_new = NULL;
+       git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
        git_diff *staged_diff_list = NULL, *index_diff_list = NULL;
        git_diff_delta *delta;
        git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
@@ -2351,8 +2359,10 @@ static int merge_check_index(size_t *conflicts, git_repository *repo, git_index
        opts.pathspec.count = staged_paths.length;
        opts.pathspec.strings = (char **)staged_paths.contents;
 
-       if ((error = git_iterator_for_index(&iter_repo, index_repo, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0 ||
-               (error = git_iterator_for_index(&iter_new, index_new, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0 ||
+       iter_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE;
+
+       if ((error = git_iterator_for_index(&iter_repo, index_repo, &iter_opts)) < 0 ||
+               (error = git_iterator_for_index(&iter_new, index_new, &iter_opts)) < 0 ||
                (error = git_diff__from_iterators(&index_diff_list, repo, iter_repo, iter_new, &opts)) < 0)
                goto done;
 
@@ -2414,6 +2424,7 @@ int git_merge__check_result(git_repository *repo, git_index *index_new)
 {
        git_tree *head_tree = NULL;
        git_iterator *iter_head = NULL, *iter_new = NULL;
+       git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
        git_diff *merged_list = NULL;
        git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
        git_diff_delta *delta;
@@ -2422,9 +2433,11 @@ int git_merge__check_result(git_repository *repo, git_index *index_new)
        const git_index_entry *e;
        int error = 0;
 
+       iter_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE;
+
        if ((error = git_repository_head_tree(&head_tree, repo)) < 0 ||
-               (error = git_iterator_for_tree(&iter_head, head_tree, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0 ||
-               (error = git_iterator_for_index(&iter_new, index_new, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0 ||
+               (error = git_iterator_for_tree(&iter_head, head_tree, &iter_opts)) < 0 ||
+               (error = git_iterator_for_index(&iter_new, index_new, &iter_opts)) < 0 ||
                (error = git_diff__from_iterators(&merged_list, repo, iter_head, iter_new, &opts)) < 0)
                goto done;
 
index ef4b41b3164a3c364d0920c31559ce37643a2529..fe8d2164f3c0d36d8c9e781de8f66660b8f922d6 100644 (file)
@@ -663,7 +663,7 @@ int git_note_iterator_new(
        if (error < 0)
                goto cleanup;
 
-       if ((error = git_iterator_for_tree(it, tree, 0, NULL, NULL)) < 0)
+       if ((error = git_iterator_for_tree(it, tree, NULL)) < 0)
                git_iterator_free(*it);
 
 cleanup:
index fab6f9a76a0ba41b410511e29f1456898190f9a8..9304da7050a4e3b61f5dd293f9238508e449cf95 100644 (file)
@@ -524,16 +524,16 @@ int git_pathspec_match_workdir(
        uint32_t flags,
        git_pathspec *ps)
 {
-       int error = 0;
        git_iterator *iter;
+       git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
+       int error = 0;
 
        assert(repo);
 
-       if (!(error = git_iterator_for_workdir(
-                       &iter, repo, NULL, NULL, pathspec_match_iter_flags(flags), NULL, NULL))) {
+       iter_opts.flags = pathspec_match_iter_flags(flags);
 
+       if (!(error = git_iterator_for_workdir(&iter, repo, NULL, NULL, &iter_opts))) {
                error = pathspec_match_from_iterator(out, iter, flags, ps);
-
                git_iterator_free(iter);
        }
 
@@ -546,16 +546,16 @@ int git_pathspec_match_index(
        uint32_t flags,
        git_pathspec *ps)
 {
-       int error = 0;
        git_iterator *iter;
+       git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
+       int error = 0;
 
        assert(index);
 
-       if (!(error = git_iterator_for_index(
-                       &iter, index, pathspec_match_iter_flags(flags), NULL, NULL))) {
+       iter_opts.flags = pathspec_match_iter_flags(flags);
 
+       if (!(error = git_iterator_for_index(&iter, index, &iter_opts))) {
                error = pathspec_match_from_iterator(out, iter, flags, ps);
-
                git_iterator_free(iter);
        }
 
@@ -568,16 +568,16 @@ int git_pathspec_match_tree(
        uint32_t flags,
        git_pathspec *ps)
 {
-       int error = 0;
        git_iterator *iter;
+       git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
+       int error = 0;
 
        assert(tree);
 
-       if (!(error = git_iterator_for_tree(
-                       &iter, tree, pathspec_match_iter_flags(flags), NULL, NULL))) {
+       iter_opts.flags = pathspec_match_iter_flags(flags);
 
+       if (!(error = git_iterator_for_tree(&iter, tree, &iter_opts))) {
                error = pathspec_match_from_iterator(out, iter, flags, ps);
-
                git_iterator_free(iter);
        }
 
index 55d535eb4b3ba8eb1a32435b4a93b51e79c9f768..1ddce464960f4ac4036e96a4b58c470058d4cbc6 100644 (file)
@@ -480,14 +480,16 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
        int error = 0;
        git_buf path = GIT_BUF_INIT;
        git_iterator *fsit = NULL;
+       git_iterator_options fsit_opts = GIT_ITERATOR_OPTIONS_INIT;
        const git_index_entry *entry = NULL;
 
        if (!backend->path) /* do nothing if no path for loose refs */
                return 0;
 
+       fsit_opts.flags = backend->iterator_flags;
+
        if ((error = git_buf_printf(&path, "%s/refs", backend->path)) < 0 ||
-               (error = git_iterator_for_filesystem(
-                       &fsit, path.ptr, backend->iterator_flags, NULL, NULL)) < 0) {
+               (error = git_iterator_for_filesystem(&fsit, path.ptr, &fsit_opts)) < 0) {
                git_buf_free(&path);
                return error;
        }
index fcb1112acc7e8ed209ea2d5bbde74f7b4e0c73cf..35824659af6594d965134a90d586e94487311012 100644 (file)
@@ -679,12 +679,14 @@ static int merge_indexes(
        git_index *theirs_index)
 {
        git_iterator *ancestor = NULL, *ours = NULL, *theirs = NULL;
-       const git_iterator_flag_t flags = GIT_ITERATOR_DONT_IGNORE_CASE;
+       git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
        int error;
 
-       if ((error = git_iterator_for_tree(&ancestor, ancestor_tree, flags, NULL, NULL)) < 0 ||
-               (error = git_iterator_for_index(&ours, ours_index, flags, NULL, NULL)) < 0 ||
-               (error = git_iterator_for_index(&theirs, theirs_index, flags, NULL, NULL)) < 0)
+       iter_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE;
+
+       if ((error = git_iterator_for_tree(&ancestor, ancestor_tree, &iter_opts)) < 0 ||
+               (error = git_iterator_for_index(&ours, ours_index, &iter_opts)) < 0 ||
+               (error = git_iterator_for_index(&theirs, theirs_index, &iter_opts)) < 0)
                goto done;
 
        error = git_merge__iterators(out, repo, ancestor, ours, theirs, NULL);
@@ -704,12 +706,14 @@ static int merge_index_and_tree(
        git_tree *theirs_tree)
 {
        git_iterator *ancestor = NULL, *ours = NULL, *theirs = NULL;
-       const git_iterator_flag_t flags = GIT_ITERATOR_DONT_IGNORE_CASE;
+       git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
        int error;
 
-       if ((error = git_iterator_for_tree(&ancestor, ancestor_tree, flags, NULL, NULL)) < 0 ||
-               (error = git_iterator_for_index(&ours, ours_index, flags, NULL, NULL)) < 0 ||
-               (error = git_iterator_for_tree(&theirs, theirs_tree, flags, NULL, NULL)) < 0)
+       iter_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE;
+
+       if ((error = git_iterator_for_tree(&ancestor, ancestor_tree, &iter_opts)) < 0 ||
+               (error = git_iterator_for_index(&ours, ours_index, &iter_opts)) < 0 ||
+               (error = git_iterator_for_tree(&theirs, theirs_tree, &iter_opts)) < 0)
                goto done;
 
        error = git_merge__iterators(out, repo, ancestor, ours, theirs, NULL);
@@ -797,14 +801,15 @@ static int stage_new_files(
        git_tree *tree)
 {
        git_iterator *iterators[2] = { NULL, NULL };
+       git_iterator_options iterator_options = GIT_ITERATOR_OPTIONS_INIT;
        git_index *index = NULL;
        int error;
 
        if ((error = git_index_new(&index)) < 0 ||
-               (error = git_iterator_for_tree(&iterators[0], parent_tree,
-                       GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0 ||
-               (error = git_iterator_for_tree(&iterators[1], tree,
-                       GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0)
+               (error = git_iterator_for_tree(
+                       &iterators[0], parent_tree, &iterator_options)) < 0 ||
+               (error = git_iterator_for_tree(
+                       &iterators[1], tree, &iterator_options)) < 0)
                goto done;
 
        error = git_iterator_walk(iterators, 2, stage_new_file, index);
index 991ebc8f396d4f3bfa2f08c527eb4a358124b6ed..7f52c36168535c7ee96a1c5b9a6f24e2ccec799c 100644 (file)
@@ -286,7 +286,7 @@ static int submodules_from_index(git_strmap *map, git_index *idx)
        git_iterator *i;
        const git_index_entry *entry;
 
-       if ((error = git_iterator_for_index(&i, idx, 0, NULL, NULL)) < 0)
+       if ((error = git_iterator_for_index(&i, idx, NULL)) < 0)
                return error;
 
        while (!(error = git_iterator_advance(&entry, i))) {
@@ -322,7 +322,7 @@ static int submodules_from_head(git_strmap *map, git_tree *head)
        git_iterator *i;
        const git_index_entry *entry;
 
-       if ((error = git_iterator_for_tree(&i, head, 0, NULL, NULL)) < 0)
+       if ((error = git_iterator_for_tree(&i, head, NULL)) < 0)
                return error;
 
        while (!(error = git_iterator_advance(&entry, i))) {
index 6011c6a9b7d3e2f19ff83cda7e4c452c57414c2c..eafb1b9da430fee1b4f1c2e67e7c1192c18f47d3 100644 (file)
@@ -30,13 +30,17 @@ static void tree_iterator_test(
 {
        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, GIT_ITERATOR_DONT_IGNORE_CASE, start, end));
+       cl_git_pass(git_iterator_for_tree(&i, t, &i_opts));
 
        /* test loop */
        while (!(error = git_iterator_advance(&entry, i))) {
@@ -297,6 +301,7 @@ 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;
@@ -306,8 +311,9 @@ void test_diff_iterator__tree_special_functions(void)
                repo, "24fa9a9fc4e202313e24b648087495441dab432b");
        cl_assert(t != NULL);
 
-       cl_git_pass(git_iterator_for_tree(
-               &i, t, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, 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);
@@ -365,11 +371,16 @@ static void index_iterator_test(
        const git_index_entry *entry;
        int error, count = 0, caps;
        git_repository *repo = cl_git_sandbox_init(sandbox);
+       git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
 
        cl_git_pass(git_repository_index(&index, repo));
        caps = git_index_caps(index);
 
-       cl_git_pass(git_iterator_for_index(&i, index, flags, start, end));
+       iter_opts.flags = flags;
+       iter_opts.start = start;
+       iter_opts.end = end;
+
+       cl_git_pass(git_iterator_for_index(&i, index, &iter_opts));
 
        while (!(error = git_iterator_advance(&entry, i))) {
                cl_assert(entry);
@@ -581,12 +592,16 @@ static void workdir_iterator_test(
        const char *an_ignored_name)
 {
        git_iterator *i;
+       git_iterator_options i_opts = GIT_ITERATOR_OPTIONS_INIT;
        const git_index_entry *entry;
        int error, count = 0, count_all = 0, count_all_post_reset = 0;
        git_repository *repo = cl_git_sandbox_init(sandbox);
 
-       cl_git_pass(git_iterator_for_workdir(
-               &i, repo, NULL, NULL, GIT_ITERATOR_DONT_AUTOEXPAND, start, end));
+       i_opts.flags = GIT_ITERATOR_DONT_AUTOEXPAND;
+       i_opts.start = start;
+       i_opts.end = end;
+
+       cl_git_pass(git_iterator_for_workdir(&i, repo, NULL, NULL, &i_opts));
 
        error = git_iterator_current(&entry, i);
        cl_assert((error == 0 && entry != NULL) ||
@@ -765,6 +780,7 @@ void test_diff_iterator__workdir_builtin_ignores(void)
 {
        git_repository *repo = cl_git_sandbox_init("attr");
        git_iterator *i;
+       git_iterator_options i_opts = GIT_ITERATOR_OPTIONS_INIT;
        const git_index_entry *entry;
        int idx;
        static struct {
@@ -796,8 +812,12 @@ void test_diff_iterator__workdir_builtin_ignores(void)
        cl_git_pass(p_mkdir("attr/sub/sub/.git", 0777));
        cl_git_mkfile("attr/sub/.git", "whatever");
 
+       i_opts.flags = GIT_ITERATOR_DONT_AUTOEXPAND;
+       i_opts.start = "dir";
+       i_opts.end = "sub/sub/file";
+
        cl_git_pass(git_iterator_for_workdir(
-               &i, repo, NULL, NULL, GIT_ITERATOR_DONT_AUTOEXPAND, "dir", "sub/sub/file"));
+               &i, repo, NULL, NULL, &i_opts));
        cl_git_pass(git_iterator_current(&entry, i));
 
        for (idx = 0; entry != NULL; ++idx) {
@@ -827,12 +847,17 @@ static void check_wd_first_through_third_range(
        git_repository *repo, const char *start, const char *end)
 {
        git_iterator *i;
+       git_iterator_options i_opts = GIT_ITERATOR_OPTIONS_INIT;
        const git_index_entry *entry;
        int error, idx;
        static const char *expected[] = { "FIRST", "second", "THIRD", NULL };
 
+       i_opts.flags = GIT_ITERATOR_IGNORE_CASE;
+       i_opts.start = start;
+       i_opts.end = end;
+
        cl_git_pass(git_iterator_for_workdir(
-               &i, repo, NULL, NULL, GIT_ITERATOR_IGNORE_CASE, start, end));
+               &i, repo, NULL, NULL, &i_opts));
        cl_git_pass(git_iterator_current(&entry, i));
 
        for (idx = 0; entry != NULL; ++idx) {
@@ -877,14 +902,16 @@ static void check_tree_range(
 {
        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,
-               ignore_case ? GIT_ITERATOR_IGNORE_CASE : GIT_ITERATOR_DONT_IGNORE_CASE,
-               start, end));
+       cl_git_pass(git_iterator_for_tree(&i, head, &i_opts));
 
        for (count = 0; !(error = git_iterator_advance(NULL, i)); ++count)
                /* count em up */;
@@ -931,6 +958,7 @@ static void check_index_range(
 {
        git_index *index;
        git_iterator *i;
+       git_iterator_options i_opts = GIT_ITERATOR_OPTIONS_INIT;
        int error, count, caps;
        bool is_ignoring_case;
 
@@ -942,7 +970,11 @@ static void check_index_range(
        if (ignore_case != is_ignoring_case)
                cl_git_pass(git_index_set_caps(index, caps ^ GIT_INDEXCAP_IGNORE_CASE));
 
-       cl_git_pass(git_iterator_for_index(&i, index, 0, start, end));
+       i_opts.flags = 0;
+       i_opts.start = start;
+       i_opts.end = end;
+
+       cl_git_pass(git_iterator_for_index(&i, index, &i_opts));
 
        cl_assert(git_iterator_ignore_case(i) == ignore_case);
 
index b96c4c4dbed980ce9e47d354ed717ab97831b8b6..f21d99b6d2dcdef814c0fd7feaec7c65c69cd364 100644 (file)
@@ -44,6 +44,7 @@ static void test_find_differences(
     git_oid ancestor_oid, ours_oid, theirs_oid;
     git_tree *ancestor_tree, *ours_tree, *theirs_tree;
        git_iterator *ancestor_iter, *ours_iter, *theirs_iter;
+       git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
 
        git_merge_options opts = GIT_MERGE_OPTIONS_INIT;
        opts.tree_flags |= GIT_MERGE_TREE_FIND_RENAMES;
@@ -67,12 +68,11 @@ static void test_find_differences(
        cl_git_pass(git_tree_lookup(&ours_tree, repo, &ours_oid));
        cl_git_pass(git_tree_lookup(&theirs_tree, repo, &theirs_oid));
 
-       cl_git_pass(git_iterator_for_tree(&ancestor_iter, ancestor_tree,
-                       GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL));
-       cl_git_pass(git_iterator_for_tree(&ours_iter, ours_tree,
-                       GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL));
-       cl_git_pass(git_iterator_for_tree(&theirs_iter, theirs_tree,
-                       GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL));
+       iter_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE;
+
+       cl_git_pass(git_iterator_for_tree(&ancestor_iter, ancestor_tree, &iter_opts));
+       cl_git_pass(git_iterator_for_tree(&ours_iter, ours_tree, &iter_opts));
+       cl_git_pass(git_iterator_for_tree(&theirs_iter, theirs_tree, &iter_opts));
 
        cl_git_pass(git_merge_diff_list__find_differences(merge_diff_list, ancestor_iter, ours_iter, theirs_iter));
        cl_git_pass(git_merge_diff_list__find_renames(repo, merge_diff_list, &opts));
index bb2d3a1867b22abe885de196d6667aaa047d829f..4d0d12be1c506b2b5a8b98543199b7fac1e65c3c 100644 (file)
@@ -126,6 +126,7 @@ static void expect_iterator_items(
 void test_repo_iterator__index(void)
 {
        git_iterator *i;
+       git_iterator_options i_opts = GIT_ITERATOR_OPTIONS_INIT;
        git_index *index;
 
        g_repo = cl_git_sandbox_init("icase");
@@ -133,19 +134,19 @@ void test_repo_iterator__index(void)
        cl_git_pass(git_repository_index(&index, g_repo));
 
        /* autoexpand with no tree entries for index */
-       cl_git_pass(git_iterator_for_index(&i, index, 0, NULL, NULL));
+       cl_git_pass(git_iterator_for_index(&i, index, NULL));
        expect_iterator_items(i, 20, NULL, 20, NULL);
        git_iterator_free(i);
 
        /* auto expand with tree entries */
-       cl_git_pass(git_iterator_for_index(
-               &i, index, GIT_ITERATOR_INCLUDE_TREES, NULL, NULL));
+       i_opts.flags = GIT_ITERATOR_INCLUDE_TREES;
+       cl_git_pass(git_iterator_for_index(&i, index, &i_opts));
        expect_iterator_items(i, 22, NULL, 22, NULL);
        git_iterator_free(i);
 
        /* no auto expand (implies trees included) */
-       cl_git_pass(git_iterator_for_index(
-               &i, index, GIT_ITERATOR_DONT_AUTOEXPAND, NULL, NULL));
+       i_opts.flags = GIT_ITERATOR_DONT_AUTOEXPAND;
+       cl_git_pass(git_iterator_for_index(&i, index, &i_opts));
        expect_iterator_items(i, 12, NULL, 22, NULL);
        git_iterator_free(i);
 
@@ -155,6 +156,7 @@ void test_repo_iterator__index(void)
 void test_repo_iterator__index_icase(void)
 {
        git_iterator *i;
+       git_iterator_options i_opts = GIT_ITERATOR_OPTIONS_INIT;
        git_index *index;
        int caps;
 
@@ -167,32 +169,45 @@ void test_repo_iterator__index_icase(void)
        cl_git_pass(git_index_set_caps(index, caps & ~GIT_INDEXCAP_IGNORE_CASE));
 
        /* autoexpand with no tree entries over range */
-       cl_git_pass(git_iterator_for_index(&i, index, 0, "c", "k/D"));
+       i_opts.start = "c";
+       i_opts.end = "k/D";
+       cl_git_pass(git_iterator_for_index(&i, index, &i_opts));
        expect_iterator_items(i, 7, NULL, 7, NULL);
        git_iterator_free(i);
 
-       cl_git_pass(git_iterator_for_index(&i, index, 0, "k", "k/Z"));
+       i_opts.start = "k";
+       i_opts.end = "k/Z";
+       cl_git_pass(git_iterator_for_index(&i, index, &i_opts));
        expect_iterator_items(i, 3, NULL, 3, NULL);
        git_iterator_free(i);
 
        /* auto expand with tree entries */
-       cl_git_pass(git_iterator_for_index(
-               &i, index, GIT_ITERATOR_INCLUDE_TREES, "c", "k/D"));
+       i_opts.flags = GIT_ITERATOR_INCLUDE_TREES;
+
+       i_opts.start = "c";
+       i_opts.end = "k/D";
+       cl_git_pass(git_iterator_for_index(&i, index, &i_opts));
        expect_iterator_items(i, 8, NULL, 8, NULL);
        git_iterator_free(i);
-       cl_git_pass(git_iterator_for_index(
-               &i, index, GIT_ITERATOR_INCLUDE_TREES, "k", "k/Z"));
+
+       i_opts.start = "k";
+       i_opts.end = "k/Z";
+       cl_git_pass(git_iterator_for_index(&i, index, &i_opts));
        expect_iterator_items(i, 4, NULL, 4, NULL);
        git_iterator_free(i);
 
        /* no auto expand (implies trees included) */
-       cl_git_pass(git_iterator_for_index(
-               &i, index, GIT_ITERATOR_DONT_AUTOEXPAND, "c", "k/D"));
+       i_opts.flags = GIT_ITERATOR_DONT_AUTOEXPAND;
+
+       i_opts.start = "c";
+       i_opts.end = "k/D";
+       cl_git_pass(git_iterator_for_index(&i, index, &i_opts));
        expect_iterator_items(i, 5, NULL, 8, NULL);
        git_iterator_free(i);
 
-       cl_git_pass(git_iterator_for_index(
-               &i, index, GIT_ITERATOR_DONT_AUTOEXPAND, "k", "k/Z"));
+       i_opts.start = "k";
+       i_opts.end = "k/Z";
+       cl_git_pass(git_iterator_for_index(&i, index, &i_opts));
        expect_iterator_items(i, 1, NULL, 4, NULL);
        git_iterator_free(i);
 
@@ -200,33 +215,47 @@ void test_repo_iterator__index_icase(void)
        cl_git_pass(git_index_set_caps(index, caps | GIT_INDEXCAP_IGNORE_CASE));
 
        /* autoexpand with no tree entries over range */
-       cl_git_pass(git_iterator_for_index(&i, index, 0, "c", "k/D"));
+       i_opts.flags = 0;
+
+       i_opts.start = "c";
+       i_opts.end = "k/D";
+       cl_git_pass(git_iterator_for_index(&i, index, &i_opts));
        expect_iterator_items(i, 13, NULL, 13, NULL);
        git_iterator_free(i);
 
-       cl_git_pass(git_iterator_for_index(&i, index, 0, "k", "k/Z"));
+       i_opts.start = "k";
+       i_opts.end = "k/Z";
+       cl_git_pass(git_iterator_for_index(&i, index, &i_opts));
        expect_iterator_items(i, 5, NULL, 5, NULL);
        git_iterator_free(i);
 
        /* auto expand with tree entries */
-       cl_git_pass(git_iterator_for_index(
-               &i, index, GIT_ITERATOR_INCLUDE_TREES, "c", "k/D"));
+       i_opts.flags = GIT_ITERATOR_INCLUDE_TREES;
+
+       i_opts.start = "c";
+       i_opts.end = "k/D";
+       cl_git_pass(git_iterator_for_index(&i, index, &i_opts));
        expect_iterator_items(i, 14, NULL, 14, NULL);
        git_iterator_free(i);
 
-       cl_git_pass(git_iterator_for_index(
-               &i, index, GIT_ITERATOR_INCLUDE_TREES, "k", "k/Z"));
+       i_opts.start = "k";
+       i_opts.end = "k/Z";
+       cl_git_pass(git_iterator_for_index(&i, index, &i_opts));
        expect_iterator_items(i, 6, NULL, 6, NULL);
        git_iterator_free(i);
 
        /* no auto expand (implies trees included) */
-       cl_git_pass(git_iterator_for_index(
-               &i, index, GIT_ITERATOR_DONT_AUTOEXPAND, "c", "k/D"));
+       i_opts.flags = GIT_ITERATOR_DONT_AUTOEXPAND;
+
+       i_opts.start = "c";
+       i_opts.end = "k/D";
+       cl_git_pass(git_iterator_for_index(&i, index, &i_opts));
        expect_iterator_items(i, 9, NULL, 14, NULL);
        git_iterator_free(i);
 
-       cl_git_pass(git_iterator_for_index(
-               &i, index, GIT_ITERATOR_DONT_AUTOEXPAND, "k", "k/Z"));
+       i_opts.start = "k";
+       i_opts.end = "k/Z";
+       cl_git_pass(git_iterator_for_index(&i, index, &i_opts));
        expect_iterator_items(i, 1, NULL, 6, NULL);
        git_iterator_free(i);
 
@@ -237,6 +266,7 @@ void test_repo_iterator__index_icase(void)
 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");
@@ -244,19 +274,21 @@ void test_repo_iterator__tree(void)
        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, 0, NULL, NULL));
+       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 */
-       cl_git_pass(git_iterator_for_tree(
-               &i, head, GIT_ITERATOR_INCLUDE_TREES, NULL, NULL));
+       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) */
-       cl_git_pass(git_iterator_for_tree(
-               &i, head, GIT_ITERATOR_DONT_AUTOEXPAND, NULL, NULL));
+       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);
 
@@ -267,75 +299,98 @@ void test_repo_iterator__tree_icase(void)
 {
        git_iterator *i;
        git_tree *head;
-       git_iterator_flag_t flag;
+       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));
 
-       flag = GIT_ITERATOR_DONT_IGNORE_CASE;
+       i_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE;
 
        /* auto expand with no tree entries */
-       cl_git_pass(git_iterator_for_tree(&i, head, flag, "c", "k/D"));
+       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);
 
-       cl_git_pass(git_iterator_for_tree(&i, head, flag, "k", "k/Z"));
+       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 */
-       cl_git_pass(git_iterator_for_tree(
-               &i, head, flag | GIT_ITERATOR_INCLUDE_TREES, "c", "k/D"));
+       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);
 
-       cl_git_pass(git_iterator_for_tree(
-               &i, head, flag | GIT_ITERATOR_INCLUDE_TREES, "k", "k/Z"));
+       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) */
-       cl_git_pass(git_iterator_for_tree(
-               &i, head, flag | GIT_ITERATOR_DONT_AUTOEXPAND, "c", "k/D"));
+       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);
 
-       cl_git_pass(git_iterator_for_tree(
-               &i, head, flag | GIT_ITERATOR_DONT_AUTOEXPAND, "k", "k/Z"));
+       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);
 
-       flag = GIT_ITERATOR_IGNORE_CASE;
-
        /* auto expand with no tree entries */
-       cl_git_pass(git_iterator_for_tree(&i, head, flag, "c", "k/D"));
+       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);
 
-       cl_git_pass(git_iterator_for_tree(&i, head, flag, "k", "k/Z"));
+       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 */
-       cl_git_pass(git_iterator_for_tree(
-               &i, head, flag | GIT_ITERATOR_INCLUDE_TREES, "c", "k/D"));
+       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);
 
-       cl_git_pass(git_iterator_for_tree(
-               &i, head, flag | GIT_ITERATOR_INCLUDE_TREES, "k", "k/Z"));
+       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) */
-       cl_git_pass(git_iterator_for_tree(
-               &i, head, flag | GIT_ITERATOR_DONT_AUTOEXPAND, "c", "k/D"));
+       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);
 
-       cl_git_pass(git_iterator_for_tree(
-               &i, head, flag | GIT_ITERATOR_DONT_AUTOEXPAND, "k", "k/Z"));
+       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);
 
@@ -345,6 +400,7 @@ void test_repo_iterator__tree_icase(void)
 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",
@@ -396,19 +452,21 @@ void test_repo_iterator__tree_more(void)
        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, 0, NULL, NULL));
+       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 */
-       cl_git_pass(git_iterator_for_tree(
-               &i, head, GIT_ITERATOR_INCLUDE_TREES, NULL, NULL));
+       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) */
-       cl_git_pass(git_iterator_for_tree(
-               &i, head, GIT_ITERATOR_DONT_AUTOEXPAND, NULL, NULL));
+       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);
 
@@ -463,6 +521,8 @@ void test_repo_iterator__tree_case_conflicts_0(void)
        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[] = {
@@ -486,25 +546,23 @@ void test_repo_iterator__tree_case_conflicts_0(void)
 
        cl_git_pass(git_tree_lookup(&tree, g_repo, &tree_id));
 
-       cl_git_pass(git_iterator_for_tree(
-               &i, tree, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL));
+       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);
 
-       cl_git_pass(git_iterator_for_tree(
-               &i, tree, GIT_ITERATOR_IGNORE_CASE, NULL, NULL));
+       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);
 
-       cl_git_pass(git_iterator_for_tree(
-               &i, tree, GIT_ITERATOR_DONT_IGNORE_CASE |
-               GIT_ITERATOR_INCLUDE_TREES, NULL, NULL));
+       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);
 
-       cl_git_pass(git_iterator_for_tree(
-               &i, tree, GIT_ITERATOR_IGNORE_CASE |
-               GIT_ITERATOR_INCLUDE_TREES, NULL, NULL));
+       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);
 
@@ -517,6 +575,8 @@ void test_repo_iterator__tree_case_conflicts_1(void)
        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[] = {
@@ -541,25 +601,23 @@ void test_repo_iterator__tree_case_conflicts_1(void)
 
        cl_git_pass(git_tree_lookup(&tree, g_repo, &tree_id));
 
-       cl_git_pass(git_iterator_for_tree(
-               &i, tree, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL));
+       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);
 
-       cl_git_pass(git_iterator_for_tree(
-               &i, tree, GIT_ITERATOR_IGNORE_CASE, NULL, NULL));
+       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);
 
-       cl_git_pass(git_iterator_for_tree(
-               &i, tree, GIT_ITERATOR_DONT_IGNORE_CASE |
-               GIT_ITERATOR_INCLUDE_TREES, NULL, NULL));
+       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);
 
-       cl_git_pass(git_iterator_for_tree(
-               &i, tree, GIT_ITERATOR_IGNORE_CASE |
-               GIT_ITERATOR_INCLUDE_TREES, NULL, NULL));
+       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);
 
@@ -572,6 +630,8 @@ void test_repo_iterator__tree_case_conflicts_2(void)
        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",
@@ -639,19 +699,18 @@ void test_repo_iterator__tree_case_conflicts_2(void)
 
        cl_git_pass(git_tree_lookup(&tree, g_repo, &tree_id));
 
-       cl_git_pass(git_iterator_for_tree(
-               &i, tree, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL));
+       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);
 
-       cl_git_pass(git_iterator_for_tree(
-               &i, tree, GIT_ITERATOR_IGNORE_CASE, NULL, NULL));
+       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);
 
-       cl_git_pass(git_iterator_for_tree(
-               &i, tree, GIT_ITERATOR_IGNORE_CASE |
-               GIT_ITERATOR_INCLUDE_TREES, NULL, NULL));
+       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);
 
@@ -661,23 +720,24 @@ void test_repo_iterator__tree_case_conflicts_2(void)
 void test_repo_iterator__workdir(void)
 {
        git_iterator *i;
+       git_iterator_options i_opts = GIT_ITERATOR_OPTIONS_INIT;
 
        g_repo = cl_git_sandbox_init("icase");
 
        /* auto expand with no tree entries */
-       cl_git_pass(git_iterator_for_workdir(&i, g_repo, NULL, NULL, 0, NULL, NULL));
+       cl_git_pass(git_iterator_for_workdir(&i, g_repo, NULL, NULL, &i_opts));
        expect_iterator_items(i, 20, NULL, 20, NULL);
        git_iterator_free(i);
 
        /* auto expand with tree entries */
-       cl_git_pass(git_iterator_for_workdir(
-               &i, g_repo, NULL, NULL, GIT_ITERATOR_INCLUDE_TREES, NULL, NULL));
+       i_opts.flags = GIT_ITERATOR_INCLUDE_TREES;
+       cl_git_pass(git_iterator_for_workdir(&i, g_repo, NULL, NULL, &i_opts));
        expect_iterator_items(i, 22, NULL, 22, NULL);
        git_iterator_free(i);
 
        /* no auto expand (implies trees included) */
-       cl_git_pass(git_iterator_for_workdir(
-               &i, g_repo, NULL, NULL, GIT_ITERATOR_DONT_AUTOEXPAND, NULL, NULL));
+       i_opts.flags = GIT_ITERATOR_DONT_AUTOEXPAND;
+       cl_git_pass(git_iterator_for_workdir(&i, g_repo, NULL, NULL, &i_opts));
        expect_iterator_items(i, 12, NULL, 22, NULL);
        git_iterator_free(i);
 }
@@ -685,73 +745,97 @@ void test_repo_iterator__workdir(void)
 void test_repo_iterator__workdir_icase(void)
 {
        git_iterator *i;
-       git_iterator_flag_t flag;
+       git_iterator_options i_opts = GIT_ITERATOR_OPTIONS_INIT;
 
        g_repo = cl_git_sandbox_init("icase");
 
-       flag = GIT_ITERATOR_DONT_IGNORE_CASE;
-
        /* auto expand with no tree entries */
-       cl_git_pass(git_iterator_for_workdir(&i, g_repo, NULL, NULL, flag, "c", "k/D"));
+       i_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE;
+
+       i_opts.start = "c";
+       i_opts.end = "k/D";
+       cl_git_pass(git_iterator_for_workdir(&i, g_repo, NULL, NULL, &i_opts));
        expect_iterator_items(i, 7, NULL, 7, NULL);
        git_iterator_free(i);
 
-       cl_git_pass(git_iterator_for_workdir(&i, g_repo, NULL, NULL, flag, "k", "k/Z"));
+       i_opts.start = "k";
+       i_opts.end = "k/Z";
+       cl_git_pass(git_iterator_for_workdir(&i, g_repo, NULL, NULL, &i_opts));
        expect_iterator_items(i, 3, NULL, 3, NULL);
        git_iterator_free(i);
 
        /* auto expand with tree entries */
-       cl_git_pass(git_iterator_for_workdir(
-               &i, g_repo, NULL, NULL, flag | GIT_ITERATOR_INCLUDE_TREES, "c", "k/D"));
+       i_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE | GIT_ITERATOR_INCLUDE_TREES;
+
+       i_opts.start = "c";
+       i_opts.end = "k/D";
+       cl_git_pass(git_iterator_for_workdir(&i, g_repo, NULL, NULL, &i_opts));
        expect_iterator_items(i, 8, NULL, 8, NULL);
        git_iterator_free(i);
 
-       cl_git_pass(git_iterator_for_workdir(
-               &i, g_repo, NULL, NULL, flag | GIT_ITERATOR_INCLUDE_TREES, "k", "k/Z"));
+       i_opts.start = "k";
+       i_opts.end = "k/Z";
+       cl_git_pass(git_iterator_for_workdir(&i, g_repo, NULL, NULL, &i_opts));
        expect_iterator_items(i, 4, NULL, 4, NULL);
        git_iterator_free(i);
 
        /* no auto expand (implies trees included) */
-       cl_git_pass(git_iterator_for_workdir(
-               &i, g_repo, NULL, NULL, flag | GIT_ITERATOR_DONT_AUTOEXPAND, "c", "k/D"));
+       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_workdir(&i, g_repo, NULL, NULL, &i_opts));
        expect_iterator_items(i, 5, NULL, 8, NULL);
        git_iterator_free(i);
 
-       cl_git_pass(git_iterator_for_workdir(
-               &i, g_repo, NULL, NULL, flag | GIT_ITERATOR_DONT_AUTOEXPAND, "k", "k/Z"));
+       i_opts.start = "k";
+       i_opts.end = "k/Z";
+       cl_git_pass(git_iterator_for_workdir(&i, g_repo, NULL, NULL, &i_opts));
        expect_iterator_items(i, 1, NULL, 4, NULL);
        git_iterator_free(i);
 
-       flag = GIT_ITERATOR_IGNORE_CASE;
-
        /* auto expand with no tree entries */
-       cl_git_pass(git_iterator_for_workdir(&i, g_repo, NULL, NULL, flag, "c", "k/D"));
+       i_opts.flags = GIT_ITERATOR_IGNORE_CASE;
+
+       i_opts.start = "c";
+       i_opts.end = "k/D";
+       cl_git_pass(git_iterator_for_workdir(&i, g_repo, NULL, NULL, &i_opts));
        expect_iterator_items(i, 13, NULL, 13, NULL);
        git_iterator_free(i);
 
-       cl_git_pass(git_iterator_for_workdir(&i, g_repo, NULL, NULL, flag, "k", "k/Z"));
+       i_opts.start = "k";
+       i_opts.end = "k/Z";
+       cl_git_pass(git_iterator_for_workdir(&i, g_repo, NULL, NULL, &i_opts));
        expect_iterator_items(i, 5, NULL, 5, NULL);
        git_iterator_free(i);
 
        /* auto expand with tree entries */
-       cl_git_pass(git_iterator_for_workdir(
-               &i, g_repo, NULL, NULL, flag | GIT_ITERATOR_INCLUDE_TREES, "c", "k/D"));
+       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_workdir(&i, g_repo, NULL, NULL, &i_opts));
        expect_iterator_items(i, 14, NULL, 14, NULL);
        git_iterator_free(i);
 
-       cl_git_pass(git_iterator_for_workdir(
-               &i, g_repo, NULL, NULL, flag | GIT_ITERATOR_INCLUDE_TREES, "k", "k/Z"));
+       i_opts.start = "k";
+       i_opts.end = "k/Z";
+       cl_git_pass(git_iterator_for_workdir(&i, g_repo, NULL, NULL, &i_opts));
        expect_iterator_items(i, 6, NULL, 6, NULL);
        git_iterator_free(i);
 
        /* no auto expand (implies trees included) */
-       cl_git_pass(git_iterator_for_workdir(
-               &i, g_repo, NULL, NULL, flag | GIT_ITERATOR_DONT_AUTOEXPAND, "c", "k/D"));
+       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_workdir(&i, g_repo, NULL, NULL, &i_opts));
        expect_iterator_items(i, 9, NULL, 14, NULL);
        git_iterator_free(i);
 
-       cl_git_pass(git_iterator_for_workdir(
-               &i, g_repo, NULL, NULL, flag | GIT_ITERATOR_DONT_AUTOEXPAND, "k", "k/Z"));
+       i_opts.start = "k";
+       i_opts.end = "k/Z";
+       cl_git_pass(git_iterator_for_workdir(&i, g_repo, NULL, NULL, &i_opts));
        expect_iterator_items(i, 1, NULL, 6, NULL);
        git_iterator_free(i);
 }
@@ -796,6 +880,7 @@ static void build_workdir_tree(const char *root, int dirs, int subs)
 void test_repo_iterator__workdir_depth(void)
 {
        git_iterator *iter;
+       git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
 
        g_repo = cl_git_sandbox_init("icase");
 
@@ -804,13 +889,13 @@ void test_repo_iterator__workdir_depth(void)
        build_workdir_tree("icase/dir02/sUB01", 50, 0);
 
        /* auto expand with no tree entries */
-       cl_git_pass(git_iterator_for_workdir(&iter, g_repo, NULL, NULL, 0, NULL, NULL));
+       cl_git_pass(git_iterator_for_workdir(&iter, g_repo, NULL, NULL, &iter_opts));
        expect_iterator_items(iter, 125, NULL, 125, NULL);
        git_iterator_free(iter);
 
        /* auto expand with tree entries (empty dirs silently skipped) */
-       cl_git_pass(git_iterator_for_workdir(
-               &iter, g_repo, NULL, NULL, GIT_ITERATOR_INCLUDE_TREES, NULL, NULL));
+       iter_opts.flags = GIT_ITERATOR_INCLUDE_TREES;
+       cl_git_pass(git_iterator_for_workdir(&iter, g_repo, NULL, NULL, &iter_opts));
        expect_iterator_items(iter, 337, NULL, 337, NULL);
        git_iterator_free(iter);
 }
@@ -818,6 +903,8 @@ void test_repo_iterator__workdir_depth(void)
 void test_repo_iterator__fs(void)
 {
        git_iterator *i;
+       git_iterator_options i_opts = GIT_ITERATOR_OPTIONS_INIT;
+
        static const char *expect_base[] = {
                "DIR01/Sub02/file",
                "DIR01/sub00/file",
@@ -863,18 +950,17 @@ void test_repo_iterator__fs(void)
 
        build_workdir_tree("status/subdir", 2, 4);
 
-       cl_git_pass(git_iterator_for_filesystem(
-               &i, "status/subdir", 0, NULL, NULL));
+       cl_git_pass(git_iterator_for_filesystem(&i, "status/subdir", NULL));
        expect_iterator_items(i, 8, expect_base, 8, expect_base);
        git_iterator_free(i);
 
-       cl_git_pass(git_iterator_for_filesystem(
-               &i, "status/subdir", GIT_ITERATOR_INCLUDE_TREES, NULL, NULL));
+       i_opts.flags = GIT_ITERATOR_INCLUDE_TREES;
+       cl_git_pass(git_iterator_for_filesystem(&i, "status/subdir", &i_opts));
        expect_iterator_items(i, 18, expect_trees, 18, expect_trees);
        git_iterator_free(i);
 
-       cl_git_pass(git_iterator_for_filesystem(
-               &i, "status/subdir", GIT_ITERATOR_DONT_AUTOEXPAND, NULL, NULL));
+       i_opts.flags = GIT_ITERATOR_DONT_AUTOEXPAND;
+       cl_git_pass(git_iterator_for_filesystem(&i, "status/subdir", &i_opts));
        expect_iterator_items(i, 5, expect_noauto, 18, expect_trees);
        git_iterator_free(i);
 
@@ -882,20 +968,18 @@ void test_repo_iterator__fs(void)
        git__tsort((void **)expect_trees, 18, (git__tsort_cmp)git__strcasecmp);
        git__tsort((void **)expect_noauto, 5, (git__tsort_cmp)git__strcasecmp);
 
-       cl_git_pass(git_iterator_for_filesystem(
-               &i, "status/subdir", GIT_ITERATOR_IGNORE_CASE, NULL, NULL));
+       i_opts.flags = GIT_ITERATOR_IGNORE_CASE;
+       cl_git_pass(git_iterator_for_filesystem(&i, "status/subdir", &i_opts));
        expect_iterator_items(i, 8, expect_base, 8, expect_base);
        git_iterator_free(i);
 
-       cl_git_pass(git_iterator_for_filesystem(
-               &i, "status/subdir", GIT_ITERATOR_IGNORE_CASE |
-               GIT_ITERATOR_INCLUDE_TREES, NULL, NULL));
+       i_opts.flags = GIT_ITERATOR_IGNORE_CASE | GIT_ITERATOR_INCLUDE_TREES;
+       cl_git_pass(git_iterator_for_filesystem(&i, "status/subdir", &i_opts));
        expect_iterator_items(i, 18, expect_trees, 18, expect_trees);
        git_iterator_free(i);
 
-       cl_git_pass(git_iterator_for_filesystem(
-               &i, "status/subdir", GIT_ITERATOR_IGNORE_CASE |
-               GIT_ITERATOR_DONT_AUTOEXPAND, NULL, NULL));
+       i_opts.flags = GIT_ITERATOR_IGNORE_CASE | GIT_ITERATOR_DONT_AUTOEXPAND;
+       cl_git_pass(git_iterator_for_filesystem(&i, "status/subdir", &i_opts));
        expect_iterator_items(i, 5, expect_noauto, 18, expect_trees);
        git_iterator_free(i);
 }
@@ -923,7 +1007,7 @@ void test_repo_iterator__fs2(void)
        g_repo = cl_git_sandbox_init("testrepo");
 
        cl_git_pass(git_iterator_for_filesystem(
-               &i, "testrepo/.git/refs", 0, NULL, NULL));
+               &i, "testrepo/.git/refs", NULL));
        expect_iterator_items(i, 13, expect_base, 13, expect_base);
        git_iterator_free(i);
 }
@@ -947,7 +1031,7 @@ void test_repo_iterator__unreadable_dir(void)
        cl_git_mkfile("empty_standard_repo/r/d", "final");
 
        cl_git_pass(git_iterator_for_filesystem(
-               &i, "empty_standard_repo/r", 0, NULL, NULL));
+               &i, "empty_standard_repo/r", NULL));
 
        cl_git_pass(git_iterator_advance(&e, i)); /* a */
        cl_git_fail(git_iterator_advance(&e, i)); /* b */
index 6721ee92a91e56d222864047bb67dffdb11267f1..5f4e620531c714e6e23ae3003247e08f8b5bcf72 100644 (file)
@@ -264,6 +264,7 @@ static int confirm_submodule_status(
 void test_submodule_status__iterator(void)
 {
        git_iterator *iter;
+       git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
        const git_index_entry *entry;
        size_t i;
        static const char *expected[] = {
@@ -308,9 +309,10 @@ void test_submodule_status__iterator(void)
        git_status_options opts = GIT_STATUS_OPTIONS_INIT;
        git_index *index;
 
+       iter_opts.flags = GIT_ITERATOR_IGNORE_CASE | GIT_ITERATOR_INCLUDE_TREES;
+
        cl_git_pass(git_repository_index(&index, g_repo));
-       cl_git_pass(git_iterator_for_workdir(&iter, g_repo, index, NULL,
-               GIT_ITERATOR_IGNORE_CASE | GIT_ITERATOR_INCLUDE_TREES, NULL, NULL));
+       cl_git_pass(git_iterator_for_workdir(&iter, g_repo, index, NULL, &iter_opts));
 
        for (i = 0; !git_iterator_advance(&entry, iter); ++i)
                cl_assert_equal_s(expected[i], entry->path);
index 8a2d79c2e56986fe13e6a56b23e00d4b393f4cc5..6b86cf1a0453f544d2e6804e6e21f04ef0f48622 100644 (file)
@@ -13,10 +13,13 @@ static void *run_workdir_iterator(void *arg)
 {
        int error = 0;
        git_iterator *iter;
+       git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
        const git_index_entry *entry = NULL;
 
+       iter_opts.flags = GIT_ITERATOR_DONT_AUTOEXPAND;
+
        cl_git_pass(git_iterator_for_workdir(
-               &iter, _repo, NULL, NULL, GIT_ITERATOR_DONT_AUTOEXPAND, NULL, NULL));
+               &iter, _repo, NULL, NULL, &iter_opts));
 
        while (!error) {
                if (entry && entry->mode == GIT_FILEMODE_TREE) {