Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/checkout.c16
-rw-r--r--src/diff.c24
-rw-r--r--src/diff_output.c10
-rw-r--r--src/iterator.c118
-rw-r--r--src/iterator.h66
-rw-r--r--tests-clar/diff/iterator.c12
6 files changed, 165 insertions, 81 deletions
diff --git a/src/checkout.c b/src/checkout.c
index d5a471d0c..411bf3be7 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -224,7 +224,7 @@ static int checkout_action_wd_only(
if (!git_pathspec_match_path(
pathspec, wd->path,
(data->strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH) != 0,
- workdir->ignore_case))
+ git_iterator_ignore_case(workdir)))
return 0;
/* check if item is tracked in the index but not in the checkout diff */
@@ -1130,7 +1130,7 @@ static int checkout_data_init(
if ((error = git_config_refresh(cfg)) < 0)
goto cleanup;
- if (git_iterator_inner_type(target) == GIT_ITERATOR_INDEX) {
+ if (git_iterator_inner_type(target) == GIT_ITERATOR_TYPE_INDEX) {
/* if we are iterating over the index, don't reload */
data->index = git_iterator_index_get_index(target);
GIT_REFCOUNT_INC(data->index);
@@ -1208,6 +1208,7 @@ int git_checkout_iterator(
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);
@@ -1228,18 +1229,21 @@ int git_checkout_iterator(
diff_opts.pathspec = data.opts.paths;
/* set up iterators */
+
+ iterflags = git_iterator_ignore_case(target) ?
+ GIT_ITERATOR_IGNORE_CASE : GIT_ITERATOR_DONT_IGNORE_CASE;
+
if ((error = git_iterator_reset(target, data.pfx, data.pfx)) < 0 ||
(error = git_iterator_for_workdir_range(
- &workdir, data.repo, data.pfx, data.pfx)) < 0 ||
+ &workdir, data.repo, iterflags, data.pfx, data.pfx)) < 0 ||
(error = git_iterator_for_tree_range(
- &baseline, data.opts.baseline, data.pfx, data.pfx)) < 0)
+ &baseline, data.opts.baseline, iterflags, data.pfx, data.pfx)) < 0)
goto cleanup;
/* Handle case insensitivity for baseline if necessary */
- if (workdir->ignore_case && !baseline->ignore_case) {
+ if (git_iterator_ignore_case(workdir) != git_iterator_ignore_case(baseline))
if ((error = git_iterator_spoolandsort_push(baseline, true)) < 0)
goto cleanup;
- }
/* Generate baseline-to-target diff which will include an entry for
* every possible update that might need to be made.
diff --git a/src/diff.c b/src/diff.c
index 5e34b9221..4b60935f0 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -418,7 +418,7 @@ static int maybe_modified(
git_delta_t status = GIT_DELTA_MODIFIED;
unsigned int omode = oitem->mode;
unsigned int nmode = nitem->mode;
- bool new_is_workdir = (new_iter->type == GIT_ITERATOR_WORKDIR);
+ bool new_is_workdir = (new_iter->type == GIT_ITERATOR_TYPE_WORKDIR);
GIT_UNUSED(old_iter);
@@ -556,7 +556,9 @@ static int diff_list_init_from_iterators(
/* Use case-insensitive compare if either iterator has
* the ignore_case bit set */
- if (!old_iter->ignore_case && !new_iter->ignore_case) {
+ if (!git_iterator_ignore_case(old_iter) &&
+ !git_iterator_ignore_case(new_iter))
+ {
diff->opts.flags &= ~GIT_DIFF_DELTAS_ARE_ICASE;
diff->strcomp = git__strcmp;
@@ -714,7 +716,7 @@ int git_diff__from_iterators(
else if (git_iterator_current_is_ignored(new_iter))
delta_type = GIT_DELTA_IGNORED;
- else if (new_iter->type != GIT_ITERATOR_WORKDIR)
+ else if (new_iter->type != GIT_ITERATOR_TYPE_WORKDIR)
delta_type = GIT_DELTA_ADDED;
if (diff_delta__from_one(diff, delta_type, nitem) < 0)
@@ -786,8 +788,8 @@ int git_diff_tree_to_tree(
assert(diff && repo);
DIFF_FROM_ITERATORS(
- git_iterator_for_tree_range(&a, old_tree, pfx, pfx),
- git_iterator_for_tree_range(&b, new_tree, pfx, pfx)
+ git_iterator_for_tree_range(&a, old_tree, 0, pfx, pfx),
+ git_iterator_for_tree_range(&b, new_tree, 0, pfx, pfx)
);
return error;
@@ -808,8 +810,8 @@ int git_diff_tree_to_index(
return error;
DIFF_FROM_ITERATORS(
- git_iterator_for_tree_range(&a, old_tree, pfx, pfx),
- git_iterator_for_index_range(&b, index, pfx, pfx)
+ git_iterator_for_tree_range(&a, old_tree, 0, pfx, pfx),
+ git_iterator_for_index_range(&b, index, 0, pfx, pfx)
);
return error;
@@ -829,8 +831,8 @@ int git_diff_index_to_workdir(
return error;
DIFF_FROM_ITERATORS(
- git_iterator_for_index_range(&a, index, pfx, pfx),
- git_iterator_for_workdir_range(&b, repo, pfx, pfx)
+ git_iterator_for_index_range(&a, index, 0, pfx, pfx),
+ git_iterator_for_workdir_range(&b, repo, 0, pfx, pfx)
);
return error;
@@ -848,8 +850,8 @@ int git_diff_tree_to_workdir(
assert(diff && repo);
DIFF_FROM_ITERATORS(
- git_iterator_for_tree_range(&a, old_tree, pfx, pfx),
- git_iterator_for_workdir_range(&b, repo, pfx, pfx)
+ git_iterator_for_tree_range(&a, old_tree, 0, pfx, pfx),
+ git_iterator_for_workdir_range(&b, repo, 0, pfx, pfx)
);
return error;
diff --git a/src/diff_output.c b/src/diff_output.c
index d271e8a8e..8a7a7a2a1 100644
--- a/src/diff_output.c
+++ b/src/diff_output.c
@@ -495,7 +495,7 @@ static void diff_patch_init(
patch->old_src = patch->diff->old_src;
patch->new_src = patch->diff->new_src;
} else {
- patch->old_src = patch->new_src = GIT_ITERATOR_TREE;
+ patch->old_src = patch->new_src = GIT_ITERATOR_TYPE_TREE;
}
}
@@ -578,7 +578,7 @@ static int diff_patch_load(
*/
if ((delta->old_file.flags & GIT_DIFF_FILE_NO_DATA) == 0 &&
- patch->old_src == GIT_ITERATOR_WORKDIR) {
+ patch->old_src == GIT_ITERATOR_TYPE_WORKDIR) {
if ((error = get_workdir_content(
ctxt, delta, &delta->old_file, &patch->old_data)) < 0)
goto cleanup;
@@ -587,7 +587,7 @@ static int diff_patch_load(
}
if ((delta->new_file.flags & GIT_DIFF_FILE_NO_DATA) == 0 &&
- patch->new_src == GIT_ITERATOR_WORKDIR) {
+ patch->new_src == GIT_ITERATOR_TYPE_WORKDIR) {
if ((error = get_workdir_content(
ctxt, delta, &delta->new_file, &patch->new_data)) < 0)
goto cleanup;
@@ -596,7 +596,7 @@ static int diff_patch_load(
}
if ((delta->old_file.flags & GIT_DIFF_FILE_NO_DATA) == 0 &&
- patch->old_src != GIT_ITERATOR_WORKDIR) {
+ patch->old_src != GIT_ITERATOR_TYPE_WORKDIR) {
if ((error = get_blob_content(
ctxt, delta, &delta->old_file,
&patch->old_data, &patch->old_blob)) < 0)
@@ -606,7 +606,7 @@ static int diff_patch_load(
}
if ((delta->new_file.flags & GIT_DIFF_FILE_NO_DATA) == 0 &&
- patch->new_src != GIT_ITERATOR_WORKDIR) {
+ patch->new_src != GIT_ITERATOR_TYPE_WORKDIR) {
if ((error = get_blob_content(
ctxt, delta, &delta->new_file,
&patch->new_data, &patch->new_blob)) < 0)
diff --git a/src/iterator.c b/src/iterator.c
index 3d75dd8b5..a9df39bb8 100644
--- a/src/iterator.c
+++ b/src/iterator.c
@@ -24,12 +24,11 @@
#define ITERATOR_BASE_INIT(P,NAME_LC,NAME_UC) do { \
(P) = git__calloc(1, sizeof(NAME_LC ## _iterator)); \
GITERR_CHECK_ALLOC(P); \
- (P)->base.type = GIT_ITERATOR_ ## NAME_UC; \
+ (P)->base.type = GIT_ITERATOR_TYPE_ ## NAME_UC; \
(P)->base.cb = &(P)->cb; \
ITERATOR_SET_CB(P,NAME_LC); \
(P)->base.start = start ? git__strdup(start) : NULL; \
(P)->base.end = end ? git__strdup(end) : NULL; \
- (P)->base.ignore_case = false; \
if ((start && !(P)->base.start) || (end && !(P)->base.end)) { \
git__free(P); return -1; } \
} while (0)
@@ -54,6 +53,31 @@ static int iterator__reset_range(
return 0;
}
+static int iterator_update_ignore_case(
+ git_iterator *iter,
+ git_iterator_flag_t flags)
+{
+ int error = 0, ignore_case = -1;
+
+ if ((flags & GIT_ITERATOR_IGNORE_CASE) != 0)
+ ignore_case = true;
+ else if ((flags & GIT_ITERATOR_DONT_IGNORE_CASE) != 0)
+ ignore_case = false;
+ else {
+ git_index *index;
+
+ if (!(error = git_repository_index__weakptr(&index, iter->repo)))
+ ignore_case = (index->ignore_case != false);
+ }
+
+ if (ignore_case > 0)
+ iter->flags = (iter->flags | GIT_ITERATOR_IGNORE_CASE);
+ else if (ignore_case == 0)
+ iter->flags = (iter->flags & ~GIT_ITERATOR_IGNORE_CASE);
+
+ return error;
+}
+
static int empty_iterator__no_item(
git_iterator *iter, const git_index_entry **entry)
{
@@ -91,13 +115,14 @@ typedef struct {
git_iterator_callbacks cb;
} empty_iterator;
-int git_iterator_for_nothing(git_iterator **iter)
+int git_iterator_for_nothing(git_iterator **iter, git_iterator_flag_t flags)
{
empty_iterator *i = git__calloc(1, sizeof(empty_iterator));
GITERR_CHECK_ALLOC(i);
- i->base.type = GIT_ITERATOR_EMPTY;
+ i->base.type = GIT_ITERATOR_TYPE_EMPTY;
i->base.cb = &i->cb;
+ i->base.flags = flags;
i->cb.current = empty_iterator__no_item;
i->cb.at_end = empty_iterator__at_end;
i->cb.advance = empty_iterator__no_item;
@@ -349,6 +374,7 @@ static int tree_iterator__reset(
int git_iterator_for_tree_range(
git_iterator **iter,
git_tree *tree,
+ git_iterator_flag_t flags,
const char *start,
const char *end)
{
@@ -356,7 +382,7 @@ int git_iterator_for_tree_range(
tree_iterator *ti;
if (tree == NULL)
- return git_iterator_for_nothing(iter);
+ return git_iterator_for_nothing(iter, flags);
if ((error = git_tree__dup(&tree, tree)) < 0)
return error;
@@ -364,13 +390,23 @@ int git_iterator_for_tree_range(
ITERATOR_BASE_INIT(ti, tree, TREE);
ti->base.repo = git_tree_owner(tree);
+
+ if ((error = iterator_update_ignore_case((git_iterator *)ti, flags)) < 0)
+ goto fail;
+
+ /* TODO: implement icase support natively in tree iterators */
+ ti->base.flags = (ti->base.flags & ~GIT_ITERATOR_IGNORE_CASE);
+
ti->stack = ti->tail = tree_iterator__alloc_frame(tree, ti->base.start);
if ((error = tree_iterator__expand_tree(ti)) < 0)
- git_iterator_free((git_iterator *)ti);
- else
- *iter = (git_iterator *)ti;
+ goto fail;
+
+ *iter = (git_iterator *)ti;
+ return 0;
+fail:
+ git_iterator_free((git_iterator *)ti);
return error;
}
@@ -466,15 +502,19 @@ static void index_iterator__free(git_iterator *self)
int git_iterator_for_index_range(
git_iterator **iter,
git_index *index,
+ git_iterator_flag_t flags,
const char *start,
const char *end)
{
index_iterator *ii;
+ GIT_UNUSED(flags);
+
ITERATOR_BASE_INIT(ii, index, INDEX);
ii->base.repo = git_index_owner(index);
- ii->base.ignore_case = index->ignore_case;
+ if (index->ignore_case)
+ ii->base.flags |= GIT_ITERATOR_IGNORE_CASE;
ii->index = index;
GIT_REFCOUNT_INC(index);
@@ -530,7 +570,8 @@ static workdir_iterator_frame *workdir_iterator__alloc_frame(
workdir_iterator *wi)
{
workdir_iterator_frame *wf = git__calloc(1, sizeof(workdir_iterator_frame));
- git_vector_cmp entry_compare = CASESELECT(wi->base.ignore_case,
+ git_vector_cmp entry_compare = CASESELECT(
+ (wi->base.flags & GIT_ITERATOR_IGNORE_CASE) != 0,
git_path_with_stat_cmp_icase, git_path_with_stat_cmp);
if (wf == NULL)
@@ -592,7 +633,8 @@ static int workdir_iterator__expand_dir(workdir_iterator *wi)
GITERR_CHECK_ALLOC(wf);
error = git_path_dirload_with_stat(
- wi->path.ptr, wi->root_len, wi->base.ignore_case,
+ wi->path.ptr, wi->root_len,
+ (wi->base.flags & GIT_ITERATOR_IGNORE_CASE) != 0,
wi->base.start, wi->base.end, &wf->entries);
if (error < 0 || wf->entries.length == 0) {
@@ -775,12 +817,12 @@ static int workdir_iterator__update_entry(workdir_iterator *wi)
int git_iterator_for_workdir_range(
git_iterator **iter,
git_repository *repo,
+ git_iterator_flag_t flags,
const char *start,
const char *end)
{
int error;
workdir_iterator *wi;
- git_index *index;
assert(iter && repo);
@@ -791,13 +833,8 @@ int git_iterator_for_workdir_range(
ITERATOR_BASE_INIT(wi, workdir, WORKDIR);
wi->base.repo = repo;
- if ((error = git_repository_index__weakptr(&index, repo)) < 0) {
- git_iterator_free((git_iterator *)wi);
- return error;
- }
-
- /* Match ignore_case flag for iterator to that of the index */
- wi->base.ignore_case = index->ignore_case;
+ if ((error = iterator_update_ignore_case((git_iterator *)wi, flags)) < 0)
+ goto fail;
if (git_buf_sets(&wi->path, git_repository_workdir(repo)) < 0 ||
git_path_to_dir(&wi->path) < 0 ||
@@ -808,23 +845,24 @@ int git_iterator_for_workdir_range(
}
wi->root_len = wi->path.size;
- wi->entrycmp = wi->base.ignore_case ?
+ wi->entrycmp = (wi->base.flags & GIT_ITERATOR_IGNORE_CASE) != 0 ?
workdir_iterator__entry_cmp_icase : workdir_iterator__entry_cmp_case;
if ((error = workdir_iterator__expand_dir(wi)) < 0) {
- if (error == GIT_ENOTFOUND)
- error = 0;
- else {
- git_iterator_free((git_iterator *)wi);
- wi = NULL;
- }
+ if (error != GIT_ENOTFOUND)
+ goto fail;
+ giterr_clear();
}
*iter = (git_iterator *)wi;
+ return 0;
+fail:
+ git_iterator_free((git_iterator *)wi);
return error;
}
+
typedef struct {
/* replacement callbacks */
git_iterator_callbacks cb;
@@ -899,12 +937,12 @@ void git_iterator_spoolandsort_pop(git_iterator *self)
{
spoolandsort_callbacks *scb = (spoolandsort_callbacks *)self->cb;
- if (self->type != GIT_ITERATOR_SPOOLANDSORT)
+ if (self->type != GIT_ITERATOR_TYPE_SPOOLANDSORT)
return;
self->cb = scb->orig;
self->type = scb->orig_type;
- self->ignore_case = !self->ignore_case;
+ self->flags ^= GIT_ITERATOR_IGNORE_CASE;
spoolandsort_iterator__free_callbacks(scb);
}
@@ -921,7 +959,7 @@ int git_iterator_spoolandsort_push(git_iterator *iter, bool ignore_case)
spoolandsort_callbacks *scb;
int (*entrycomp)(const void *a, const void *b);
- if (iter->ignore_case == ignore_case)
+ if (((iter->flags & GIT_ITERATOR_IGNORE_CASE) != 0) == (ignore_case != 0))
return 0;
scb = git__calloc(1, sizeof(spoolandsort_callbacks));
@@ -964,8 +1002,8 @@ int git_iterator_spoolandsort_push(git_iterator *iter, bool ignore_case)
git_vector_sort(&scb->entries);
iter->cb = (git_iterator_callbacks *)scb;
- iter->type = GIT_ITERATOR_SPOOLANDSORT;
- iter->ignore_case = !iter->ignore_case;
+ iter->type = GIT_ITERATOR_TYPE_SPOOLANDSORT;
+ iter->flags ^= GIT_ITERATOR_IGNORE_CASE;
return 0;
@@ -992,11 +1030,11 @@ void git_iterator_free(git_iterator *iter)
git_index *git_iterator_index_get_index(git_iterator *iter)
{
- if (iter->type == GIT_ITERATOR_INDEX)
+ if (iter->type == GIT_ITERATOR_TYPE_INDEX)
return ((index_iterator *)iter)->index;
- if (iter->type == GIT_ITERATOR_SPOOLANDSORT &&
- ((spoolandsort_callbacks *)iter->cb)->orig_type == GIT_ITERATOR_INDEX)
+ if (iter->type == GIT_ITERATOR_TYPE_SPOOLANDSORT &&
+ ((spoolandsort_callbacks *)iter->cb)->orig_type == GIT_ITERATOR_TYPE_INDEX)
return ((index_iterator *)iter)->index;
return NULL;
@@ -1004,7 +1042,7 @@ git_index *git_iterator_index_get_index(git_iterator *iter)
git_iterator_type_t git_iterator_inner_type(git_iterator *iter)
{
- if (iter->type == GIT_ITERATOR_SPOOLANDSORT)
+ if (iter->type == GIT_ITERATOR_TYPE_SPOOLANDSORT)
return ((spoolandsort_callbacks *)iter->cb)->orig_type;
return iter->type;
@@ -1013,7 +1051,7 @@ git_iterator_type_t git_iterator_inner_type(git_iterator *iter)
int git_iterator_current_tree_entry(
git_iterator *iter, const git_tree_entry **tree_entry)
{
- *tree_entry = (iter->type != GIT_ITERATOR_TREE) ? NULL :
+ *tree_entry = (iter->type != GIT_ITERATOR_TYPE_TREE) ? NULL :
tree_iterator__tree_entry((tree_iterator *)iter);
return 0;
}
@@ -1027,7 +1065,7 @@ int git_iterator_current_parent_tree(
tree_iterator_frame *tf;
const char *scan = parent_path;
- if (iter->type != GIT_ITERATOR_TREE || ti->stack == NULL)
+ if (iter->type != GIT_ITERATOR_TYPE_TREE || ti->stack == NULL)
goto notfound;
for (tf = ti->tail; tf != NULL; tf = tf->prev) {
@@ -1061,7 +1099,7 @@ int git_iterator_current_is_ignored(git_iterator *iter)
{
workdir_iterator *wi = (workdir_iterator *)iter;
- if (iter->type != GIT_ITERATOR_WORKDIR)
+ if (iter->type != GIT_ITERATOR_TYPE_WORKDIR)
return 0;
if (wi->is_ignored != -1)
@@ -1078,7 +1116,7 @@ int git_iterator_advance_into_directory(
{
workdir_iterator *wi = (workdir_iterator *)iter;
- if (iter->type == GIT_ITERATOR_WORKDIR &&
+ if (iter->type == GIT_ITERATOR_TYPE_WORKDIR &&
wi->entry.path &&
(wi->entry.mode == GIT_FILEMODE_TREE ||
wi->entry.mode == GIT_FILEMODE_COMMIT))
@@ -1112,7 +1150,7 @@ int git_iterator_current_workdir_path(git_iterator *iter, git_buf **path)
{
workdir_iterator *wi = (workdir_iterator *)iter;
- if (iter->type != GIT_ITERATOR_WORKDIR || !wi->entry.path)
+ if (iter->type != GIT_ITERATOR_TYPE_WORKDIR || !wi->entry.path)
*path = NULL;
else
*path = &wi->path;
diff --git a/src/iterator.h b/src/iterator.h
index 727da97b3..67e8a42dd 100644
--- a/src/iterator.h
+++ b/src/iterator.h
@@ -12,20 +12,26 @@
#include "vector.h"
#include "buffer.h"
-#define ITERATOR_PREFIXCMP(ITER, STR, PREFIX) (((ITER).ignore_case) ? \
+#define ITERATOR_PREFIXCMP(ITER, STR, PREFIX) \
+ (((ITER).flags & GIT_ITERATOR_IGNORE_CASE) != 0 ? \
git__prefixcmp_icase((STR), (PREFIX)) : \
git__prefixcmp((STR), (PREFIX)))
typedef struct git_iterator git_iterator;
typedef enum {
- GIT_ITERATOR_EMPTY = 0,
- GIT_ITERATOR_TREE = 1,
- GIT_ITERATOR_INDEX = 2,
- GIT_ITERATOR_WORKDIR = 3,
- GIT_ITERATOR_SPOOLANDSORT = 4
+ GIT_ITERATOR_TYPE_EMPTY = 0,
+ GIT_ITERATOR_TYPE_TREE = 1,
+ GIT_ITERATOR_TYPE_INDEX = 2,
+ GIT_ITERATOR_TYPE_WORKDIR = 3,
+ GIT_ITERATOR_TYPE_SPOOLANDSORT = 4
} git_iterator_type_t;
+typedef enum {
+ GIT_ITERATOR_IGNORE_CASE = (1 << 0), /* ignore_case */
+ GIT_ITERATOR_DONT_IGNORE_CASE = (1 << 1), /* force ignore_case off */
+} git_iterator_flag_t;
+
typedef struct {
int (*current)(git_iterator *, const git_index_entry **);
int (*at_end)(git_iterator *);
@@ -41,33 +47,55 @@ struct git_iterator {
git_repository *repo;
char *start;
char *end;
- bool ignore_case;
+ unsigned int flags;
};
-extern int git_iterator_for_nothing(git_iterator **out);
+extern int git_iterator_for_nothing(
+ git_iterator **out, git_iterator_flag_t flags);
+/* tree iterators will match the ignore_case value from the index of the
+ * repository, unless you override with a non-zero flag value
+ */
extern int git_iterator_for_tree_range(
- git_iterator **out, git_tree *tree, const char *start, const char *end);
+ git_iterator **out,
+ git_tree *tree,
+ git_iterator_flag_t flags,
+ const char *start,
+ const char *end);
GIT_INLINE(int) git_iterator_for_tree(git_iterator **out, git_tree *tree)
{
- return git_iterator_for_tree_range(out, tree, NULL, NULL);
+ return git_iterator_for_tree_range(out, tree, 0, NULL, NULL);
}
+/* index iterators will take the ignore_case value from the index; the
+ * ignore_case flags are not used
+ */
extern int git_iterator_for_index_range(
- git_iterator **out, git_index *index, const char *start, const char *end);
+ git_iterator **out,
+ git_index *index,
+ git_iterator_flag_t flags,
+ const char *start,
+ const char *end);
GIT_INLINE(int) git_iterator_for_index(git_iterator **out, git_index *index)
{
- return git_iterator_for_index_range(out, index, NULL, NULL);
+ return git_iterator_for_index_range(out, index, 0, NULL, NULL);
}
+/* workdir iterators will match the ignore_case value from the index of the
+ * repository, unless you override with a non-zero flag value
+ */
extern int git_iterator_for_workdir_range(
- git_iterator **out, git_repository *repo, const char *start, const char *end);
+ git_iterator **out,
+ git_repository *repo,
+ git_iterator_flag_t flags,
+ const char *start,
+ const char *end);
GIT_INLINE(int) git_iterator_for_workdir(git_iterator **out, git_repository *repo)
{
- return git_iterator_for_workdir_range(out, repo, NULL, NULL);
+ return git_iterator_for_workdir_range(out, repo, 0, NULL, NULL);
}
extern void git_iterator_free(git_iterator *iter);
@@ -127,6 +155,16 @@ GIT_INLINE(git_repository *) git_iterator_owner(git_iterator *iter)
return iter->repo;
}
+GIT_INLINE(git_iterator_flag_t) git_iterator_flags(git_iterator *iter)
+{
+ return iter->flags;
+}
+
+GIT_INLINE(bool) git_iterator_ignore_case(git_iterator *iter)
+{
+ return ((iter->flags & GIT_ITERATOR_IGNORE_CASE) != 0);
+}
+
extern int git_iterator_current_tree_entry(
git_iterator *iter, const git_tree_entry **tree_entry);
diff --git a/tests-clar/diff/iterator.c b/tests-clar/diff/iterator.c
index de083ea36..6fc5730bc 100644
--- a/tests-clar/diff/iterator.c
+++ b/tests-clar/diff/iterator.c
@@ -35,7 +35,8 @@ static void tree_iterator_test(
git_repository *repo = cl_git_sandbox_init(sandbox);
cl_assert(t = resolve_commit_oid_to_tree(repo, treeish));
- cl_git_pass(git_iterator_for_tree_range(&i, t, start, end));
+ cl_git_pass(git_iterator_for_tree_range(
+ &i, t, GIT_ITERATOR_DONT_IGNORE_CASE, start, end));
/* test loop */
cl_git_pass(git_iterator_current(i, &entry));
@@ -304,7 +305,8 @@ void test_diff_iterator__tree_special_functions(void)
repo, "24fa9a9fc4e202313e24b648087495441dab432b");
cl_assert(t != NULL);
- cl_git_pass(git_iterator_for_tree_range(&i, t, NULL, NULL));
+ cl_git_pass(git_iterator_for_tree_range(
+ &i, t, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL));
cl_git_pass(git_iterator_current(i, &entry));
while (entry != NULL) {
@@ -362,7 +364,7 @@ static void index_iterator_test(
git_repository *repo = cl_git_sandbox_init(sandbox);
cl_git_pass(git_repository_index(&index, repo));
- cl_git_pass(git_iterator_for_index_range(&i, index, start, end));
+ cl_git_pass(git_iterator_for_index_range(&i, index, 0, start, end));
cl_git_pass(git_iterator_current(i, &entry));
while (entry != NULL) {
@@ -536,7 +538,7 @@ static void workdir_iterator_test(
int 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_range(&i, repo, start, end));
+ cl_git_pass(git_iterator_for_workdir_range(&i, repo, 0, start, end));
cl_git_pass(git_iterator_current(i, &entry));
while (entry != NULL) {
@@ -734,7 +736,7 @@ void test_diff_iterator__workdir_builtin_ignores(void)
cl_git_mkfile("attr/sub/.git", "whatever");
cl_git_pass(
- git_iterator_for_workdir_range(&i, repo, "dir", "sub/sub/file"));
+ git_iterator_for_workdir_range(&i, repo, 0, "dir", "sub/sub/file"));
cl_git_pass(git_iterator_current(i, &entry));
for (idx = 0; entry != NULL; ++idx) {