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).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
diff --git a/src/checkout.c b/src/checkout.c
index a62df5e..76119c6 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -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;
}
diff --git a/src/diff.c b/src/diff.c
index 042cdf4..82a8164 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -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) {
diff --git a/src/iterator.c b/src/iterator.c
index b154534..cf88eff 100644
--- a/src/iterator.c
+++ b/src/iterator.c
@@ -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. */
diff --git a/src/iterator.h b/src/iterator.h
index ccdab4d..c0e3560 100644
--- a/src/iterator.h
+++ b/src/iterator.h
@@ -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