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:
authorRussell Belfer <rb@github.com>2014-02-11 01:20:08 +0400
committerRussell Belfer <rb@github.com>2014-04-18 01:43:45 +0400
commit3b4c401a38ce912d5be8c9bf4ab1c4912a4f08bd (patch)
tree4961b64fd558e1e55e9d1d96b37ca575c42ce008 /src/iterator.c
parentdac160489bbf8de90d2f1ae152df68ded2603598 (diff)
Decouple index iterator sort from index
This makes the index iterator honor the GIT_ITERATOR_IGNORE_CASE and GIT_ITERATOR_DONT_IGNORE_CASE flags without modifying the index data itself. To take advantage of this, I had to export a number of the internal index entry comparison functions. I also wrote some new tests to exercise the capability.
Diffstat (limited to 'src/iterator.c')
-rw-r--r--src/iterator.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/iterator.c b/src/iterator.c
index a84f4d3db..53ef278d1 100644
--- a/src/iterator.c
+++ b/src/iterator.c
@@ -868,16 +868,20 @@ int git_iterator_for_index(
return error;
}
ii->index = index;
- ii->entry_srch = index->entries_search;
ITERATOR_BASE_INIT(ii, index, INDEX, git_index_owner(index));
- if (index->ignore_case) {
- ii->base.flags |= GIT_ITERATOR_IGNORE_CASE;
- ii->base.prefixcomp = git__prefixcmp_icase;
+ if ((error = iterator__update_ignore_case((git_iterator *)ii, flags)) < 0) {
+ git_iterator_free((git_iterator *)ii);
+ return error;
}
- /* TODO: resort entries to match desired ignore_case behavior */
+ ii->entry_srch = iterator__ignore_case(ii) ?
+ git_index_entry_isrch : git_index_entry_srch;
+
+ git_vector_set_cmp(&ii->entries, iterator__ignore_case(ii) ?
+ git_index_entry_icmp : git_index_entry_cmp);
+ git_vector_sort(&ii->entries);
git_buf_init(&ii->partial, 0);
ii->tree_entry.mode = GIT_FILEMODE_TREE;