diff options
author | Russell Belfer <rb@github.com> | 2013-01-23 03:28:25 +0400 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-01-23 03:28:25 +0400 |
commit | cce548e3e0c14b5d46c8d886c9954f4b66533ecd (patch) | |
tree | 34eb15ccbb5b17c316065ad52725b80e09857f1b /src | |
parent | 2a707d0e24e206666626ae858e5ba618ffef0547 (diff) |
Fix case sensitivity bug with tree iterators
With the new code to make tree iterators support ignore_case,
there is a bug in setting the start entry for range bounded
iterators where memcmp was being used instead of strncasecmp.
This fixes that and expands the tree iterator test to cover
the cases that were broken.
Diffstat (limited to 'src')
-rw-r--r-- | src/iterator.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/iterator.c b/src/iterator.c index 56b262975..1c36cac78 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -255,15 +255,17 @@ static int tree_iterator__icase_map_cmp(const void *a, const void *b, void *data git_tree *tree = data; const git_tree_entry *te1 = git_tree_entry_byindex(tree, (size_t)a); const git_tree_entry *te2 = git_tree_entry_byindex(tree, (size_t)b); + return te1 ? (te2 ? git_tree_entry_icmp(te1, te2) : 1) : -1; } -static int tree_iterator__frame_start_icmp(const void *key, const void *element) +static int tree_iterator__frame_start_icmp(const void *key, const void *el) { const tree_iterator_frame *tf = (const tree_iterator_frame *)key; - const git_tree_entry *te = git_tree_entry_byindex(tf->tree, (size_t)element); + const git_tree_entry *te = git_tree_entry_byindex(tf->tree, (size_t)el); + size_t minlen = min(tf->startlen, te->filename_len); - return memcmp(tf->start, te->filename, min(tf->startlen, te->filename_len)); + return git__strncasecmp(tf->start, te->filename, minlen); } static void tree_iterator__frame_seek_start(tree_iterator_frame *tf) |