Commit 546d65a8 by Russell Belfer

Fix up spoolandsort iterator usage

The spoolandsort iterator changes got sort-of cherry picked out of
this branch and so I dropped the commit when rebasing; however,
there were a few small changes that got dropped as well (since the
version merged upstream wasn't quite the same as what I dropped).
parent a9a73007
......@@ -1223,8 +1223,7 @@ int git_checkout_iterator(
/* Handle case insensitivity for baseline if necessary */
if (workdir->ignore_case && !baseline->ignore_case) {
if ((error = git_iterator_spoolandsort(
&baseline, baseline, git_index_entry__cmp_icase, true)) < 0)
if ((error = git_iterator_spoolandsort_push(baseline, true)) < 0)
goto cleanup;
}
......
......@@ -589,8 +589,7 @@ int git_diff__from_iterators(
*diff_ptr = NULL;
if (!diff ||
diff_list_init_from_iterators(diff, old_iter, new_iter) < 0)
if (!diff || diff_list_init_from_iterators(diff, old_iter, new_iter) < 0)
goto fail;
if (diff->opts.flags & GIT_DIFF_DELTAS_ARE_ICASE) {
......
......@@ -30,8 +30,8 @@
(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)) \
return -1; \
if ((start && !(P)->base.start) || (end && !(P)->base.end)) { \
git__free(P); return -1; } \
} while (0)
static int iterator__reset_range(
......@@ -990,31 +990,24 @@ fail:
git_index *git_iterator_index_get_index(git_iterator *iter)
{
if (iter->type == GIT_ITERATOR_SPOOLANDSORT)
iter = ((spoolandsort_iterator *)iter)->wrapped;
if (iter->type == GIT_ITERATOR_INDEX)
return ((index_iterator *)iter)->index;
if (iter->type == GIT_ITERATOR_SPOOLANDSORT &&
((spoolandsort_callbacks *)iter->cb)->orig_type == GIT_ITERATOR_INDEX)
return ((index_iterator *)iter)->index;
return NULL;
}
git_iterator_type_t git_iterator_inner_type(git_iterator *iter)
{
if (iter->type == GIT_ITERATOR_SPOOLANDSORT)
iter = ((spoolandsort_iterator *)iter)->wrapped;
return ((spoolandsort_callbacks *)iter->cb)->orig_type;
return iter->type;
}
git_iterator *git_iterator_spoolandsort_inner_iterator(git_iterator *iter)
{
if (iter->type == GIT_ITERATOR_SPOOLANDSORT)
return ((spoolandsort_iterator *)iter)->wrapped;
return NULL;
}
int git_iterator_current_tree_entry(
git_iterator *iter, const git_tree_entry **tree_entry)
{
......@@ -1085,8 +1078,8 @@ int git_iterator_advance_into_directory(
if (iter->type == GIT_ITERATOR_WORKDIR &&
wi->entry.path &&
S_ISDIR(wi->entry.mode) &&
!S_ISGITLINK(wi->entry.mode))
(wi->entry.mode == GIT_FILEMODE_TREE ||
wi->entry.mode == GIT_FILEMODE_COMMIT))
{
if (workdir_iterator__expand_dir(wi) < 0)
/* if error loading or if empty, skip the directory. */
......
......@@ -198,7 +198,4 @@ extern git_index *git_iterator_index_get_index(git_iterator *iter);
extern git_iterator_type_t git_iterator_inner_type(git_iterator *iter);
extern git_iterator *git_iterator_spoolandsort_inner_iterator(
git_iterator *iter);
#endif
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