Commit 21e7015c by Carlos Martín Nieto

Merge pull request #3402 from ethomson/faster_diff

Provide path matching in the iterators (for faster diffs)
parents ed38e26d 53c2296b
......@@ -129,8 +129,12 @@ typedef enum {
*/
GIT_DIFF_INCLUDE_CASECHANGE = (1u << 11),
/** If the pathspec is set in the diff options, this flags means to
* apply it as an exact match instead of as an fnmatch pattern.
/** If the pathspec is set in the diff options, this flags indicates
* that the paths will be treated as literal paths instead of
* fnmatch patterns. Each path in the list must either be a full
* path to a file or a directory. (A trailing slash indicates that
* the path will _only_ match a directory). If a directory is
* specified, all children will be included.
*/
GIT_DIFF_DISABLE_PATHSPEC_MATCH = (1u << 12),
......
......@@ -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)
......@@ -2646,6 +2652,7 @@ int git_checkout_tree(
git_index *index;
git_tree *tree = NULL;
git_iterator *tree_i = NULL;
git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
if (!treeish && !repo) {
giterr_set(GITERR_CHECKOUT,
......@@ -2681,7 +2688,12 @@ 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 ((opts->checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)) {
iter_opts.pathlist.count = opts->paths.count;
iter_opts.pathlist.strings = opts->paths.strings;
}
if (!(error = git_iterator_for_tree(&tree_i, tree, &iter_opts)))
error = git_checkout_iterator(tree_i, index, opts);
git_iterator_free(tree_i);
......
......@@ -74,6 +74,23 @@ static int diff_insert_delta(
return error;
}
static bool diff_pathspec_match(
const char **matched_pathspec, git_diff *diff, const char *path)
{
/* The iterator has filtered out paths for us, so the fact that we're
* seeing this patch means that it must match the given path list.
*/
if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_DISABLE_PATHSPEC_MATCH)) {
*matched_pathspec = path;
return true;
}
return git_pathspec__match(
&diff->pathspec, path, false,
DIFF_FLAG_IS_SET(diff, GIT_DIFF_IGNORE_CASE),
matched_pathspec, NULL);
}
static int diff_delta__from_one(
git_diff *diff,
git_delta_t status,
......@@ -110,11 +127,7 @@ static int diff_delta__from_one(
DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_INCLUDE_UNREADABLE))
return 0;
if (!git_pathspec__match(
&diff->pathspec, entry->path,
DIFF_FLAG_IS_SET(diff, GIT_DIFF_DISABLE_PATHSPEC_MATCH),
DIFF_FLAG_IS_SET(diff, GIT_DIFF_IGNORE_CASE),
&matched_pathspec, NULL))
if (!diff_pathspec_match(&matched_pathspec, diff, entry->path))
return 0;
delta = diff_delta__alloc(diff, status, entry->path);
......@@ -755,11 +768,7 @@ static int maybe_modified(
const char *matched_pathspec;
int error = 0;
if (!git_pathspec__match(
&diff->pathspec, oitem->path,
DIFF_FLAG_IS_SET(diff, GIT_DIFF_DISABLE_PATHSPEC_MATCH),
DIFF_FLAG_IS_SET(diff, GIT_DIFF_IGNORE_CASE),
&matched_pathspec, NULL))
if (!diff_pathspec_match(&matched_pathspec, diff, oitem->path))
return 0;
memset(&noid, 0, sizeof(noid));
......@@ -1053,6 +1062,12 @@ static int handle_unmatched_new_item(
&info->nitem, &untracked_state, info->new_iter)) < 0)
return error;
/* if we found nothing that matched our pathlist filter, exclude */
if (untracked_state == GIT_ITERATOR_STATUS_FILTERED) {
git_vector_pop(&diff->deltas);
git__free(last);
}
/* if we found nothing or just ignored items, update the record */
if (untracked_state == GIT_ITERATOR_STATUS_IGNORED ||
untracked_state == GIT_ITERATOR_STATUS_EMPTY) {
......@@ -1264,11 +1279,26 @@ 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; \
char *pfx = (opts && !(opts->flags & GIT_DIFF_DISABLE_PATHSPEC_MATCH)) ? \
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)) \
if (opts && (opts->flags & GIT_DIFF_DISABLE_PATHSPEC_MATCH)) { \
a_opts.pathlist.strings = opts->pathspec.strings; \
a_opts.pathlist.count = opts->pathspec.count; \
b_opts.pathlist.strings = opts->pathspec.strings; \
b_opts.pathlist.count = opts->pathspec.count; \
} \
if (!error && !(error = MAKE_FIRST) && !(error = MAKE_SECOND)) \
error = git_diff__from_iterators(diff, repo, a, b, opts); \
git__free(pfx); git_iterator_free(a); git_iterator_free(b); \
} while (0)
......@@ -1280,8 +1310,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 +1323,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 +1348,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 +1361,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 +1386,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 +1414,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 +1463,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 */
......
......@@ -728,6 +728,7 @@ static int truncate_racily_clean(git_index *index)
if (!is_racy_timestamp(ts, entry))
continue;
/* TODO: use the (non-fnmatching) filelist iterator */
diff_opts.pathspec.count = 1;
diff_opts.pathspec.strings = (char **) &entry->path;
......@@ -2658,6 +2659,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 +2669,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 &&
......
......@@ -39,6 +39,21 @@ typedef enum {
} git_iterator_flag_t;
typedef struct {
const char *start;
const char *end;
/* paths to include in the iterator (literal). if set, any paths not
* listed here will be excluded from iteration.
*/
git_strarray pathlist;
/* 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 *);
int (*advance_into)(const git_index_entry **, git_iterator *);
......@@ -54,6 +69,10 @@ struct git_iterator {
git_repository *repo;
char *start;
char *end;
git_vector pathlist;
size_t pathlist_walk_idx;
int (*strcomp)(const char *a, const char *b);
int (*strncomp)(const char *a, const char *b, size_t n);
int (*prefixcomp)(const char *str, const char *prefix);
size_t stat_calls;
unsigned int flags;
......@@ -61,9 +80,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 +88,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 +96,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 +104,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 +114,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 +125,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);
......@@ -271,7 +278,8 @@ extern git_index *git_iterator_get_index(git_iterator *iter);
typedef enum {
GIT_ITERATOR_STATUS_NORMAL = 0,
GIT_ITERATOR_STATUS_IGNORED = 1,
GIT_ITERATOR_STATUS_EMPTY = 2
GIT_ITERATOR_STATUS_EMPTY = 2,
GIT_ITERATOR_STATUS_FILTERED = 3
} git_iterator_status_t;
/* Advance over a directory and check if it contains no files or just
......
......@@ -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;
......@@ -2348,11 +2356,12 @@ static int merge_check_index(size_t *conflicts, git_repository *repo, git_index
goto done;
}
opts.pathspec.count = staged_paths.length;
opts.pathspec.strings = (char **)staged_paths.contents;
iter_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE;
iter_opts.pathlist.strings = (char **)staged_paths.contents;
iter_opts.pathlist.count = staged_paths.length;
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 ||
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;
......@@ -2396,6 +2405,7 @@ static int merge_check_workdir(size_t *conflicts, git_repository *repo, git_inde
* will be applied by the merge (including conflicts). Ensure that there
* are no changes in the workdir to these paths.
*/
opts.flags |= GIT_DIFF_DISABLE_PATHSPEC_MATCH;
opts.pathspec.count = merged_paths->length;
opts.pathspec.strings = (char **)merged_paths->contents;
......@@ -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;
......
......@@ -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:
......
......@@ -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);
}
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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))) {
......
......@@ -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);
......
......@@ -444,6 +444,216 @@ void test_diff_workdir__to_index_with_pathspec(void)
git_diff_free(diff);
}
void test_diff_workdir__to_index_with_pathlist_disabling_fnmatch(void)
{
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
git_diff *diff = NULL;
diff_expects exp;
char *pathspec = NULL;
int use_iterator;
g_repo = cl_git_sandbox_init("status");
opts.context_lines = 3;
opts.interhunk_lines = 1;
opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED |
GIT_DIFF_DISABLE_PATHSPEC_MATCH;
opts.pathspec.strings = &pathspec;
opts.pathspec.count = 0;
/* ensure that an empty pathspec list is ignored */
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff, diff_file_cb, NULL, NULL, NULL, &exp));
else
cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(13, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
cl_assert_equal_i(4, exp.file_status[GIT_DELTA_DELETED]);
cl_assert_equal_i(4, exp.file_status[GIT_DELTA_MODIFIED]);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_IGNORED]);
cl_assert_equal_i(4, exp.file_status[GIT_DELTA_UNTRACKED]);
}
git_diff_free(diff);
/* ensure that a single NULL pathspec is filtered out (like when using
* fnmatch filtering)
*/
opts.pathspec.count = 1;
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff, diff_file_cb, NULL, NULL, NULL, &exp));
else
cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(13, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
cl_assert_equal_i(4, exp.file_status[GIT_DELTA_DELETED]);
cl_assert_equal_i(4, exp.file_status[GIT_DELTA_MODIFIED]);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_IGNORED]);
cl_assert_equal_i(4, exp.file_status[GIT_DELTA_UNTRACKED]);
}
git_diff_free(diff);
pathspec = "modified_file";
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff, diff_file_cb, NULL, NULL, NULL, &exp));
else
cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(1, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_DELETED]);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_MODIFIED]);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_IGNORED]);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_UNTRACKED]);
}
git_diff_free(diff);
/* ensure that subdirs can be specified */
pathspec = "subdir";
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff, diff_file_cb, NULL, NULL, NULL, &exp));
else
cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(3, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_MODIFIED]);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_IGNORED]);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNTRACKED]);
}
git_diff_free(diff);
/* ensure that subdirs can be specified with a trailing slash */
pathspec = "subdir/";
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff, diff_file_cb, NULL, NULL, NULL, &exp));
else
cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(3, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_MODIFIED]);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_IGNORED]);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNTRACKED]);
}
git_diff_free(diff);
/* ensure that fnmatching is completely disabled */
pathspec = "subdir/*";
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff, diff_file_cb, NULL, NULL, NULL, &exp));
else
cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(0, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_DELETED]);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_MODIFIED]);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_IGNORED]);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_UNTRACKED]);
}
git_diff_free(diff);
/* ensure that the prefix matching isn't completely braindead */
pathspec = "subdi";
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff, diff_file_cb, NULL, NULL, NULL, &exp));
else
cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(0, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_DELETED]);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_MODIFIED]);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_IGNORED]);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_UNTRACKED]);
}
git_diff_free(diff);
/* ensure that fnmatching isn't working at all */
pathspec = "*_deleted";
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff, diff_file_cb, NULL, NULL, NULL, &exp));
else
cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(0, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_DELETED]);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_MODIFIED]);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_IGNORED]);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_UNTRACKED]);
}
git_diff_free(diff);
}
void test_diff_workdir__filemode_changes(void)
{
git_diff *diff = NULL;
......
......@@ -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));
......
......@@ -191,10 +191,10 @@ void test_status_worktree_init__bracket_in_filename(void)
cl_git_pass(git_status_file(&status_flags, repo, FILE_WITHOUT_BRACKET));
cl_assert(status_flags == GIT_STATUS_WT_NEW);
cl_git_pass(git_status_file(&status_flags, repo, "LICENSE\\[1\\].md"));
cl_assert(status_flags == GIT_STATUS_INDEX_NEW);
cl_git_fail_with(git_status_file(&status_flags, repo, "LICENSE\\[1\\].md"), GIT_ENOTFOUND);
cl_git_pass(git_status_file(&status_flags, repo, FILE_WITH_BRACKET));
cl_assert(status_flags == GIT_STATUS_INDEX_NEW);
git_index_free(index);
git_repository_free(repo);
......
......@@ -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);
......
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment