diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/iterator.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/iterator.c b/src/iterator.c index 0db929211..d00b8aa62 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -1521,7 +1521,7 @@ static void filesystem_iterator_set_current( static int filesystem_iterator_current( const git_index_entry **out, git_iterator *i) { - filesystem_iterator *iter = (filesystem_iterator *)i; + filesystem_iterator *iter = GIT_CONTAINER_OF(i, filesystem_iterator, base); if (!iterator__has_been_accessed(i)) return iter->base.cb->advance(out, i); @@ -1568,7 +1568,7 @@ done: static int filesystem_iterator_advance( const git_index_entry **out, git_iterator *i) { - filesystem_iterator *iter = (filesystem_iterator *)i; + filesystem_iterator *iter = GIT_CONTAINER_OF(i, filesystem_iterator, base); bool is_dir; int error = 0; @@ -1627,7 +1627,7 @@ static int filesystem_iterator_advance( static int filesystem_iterator_advance_into( const git_index_entry **out, git_iterator *i) { - filesystem_iterator *iter = (filesystem_iterator *)i; + filesystem_iterator *iter = GIT_CONTAINER_OF(i, filesystem_iterator, base); filesystem_iterator_frame *frame; filesystem_iterator_entry *prev_entry; int error; @@ -1664,7 +1664,7 @@ static int filesystem_iterator_advance_into( int git_iterator_current_workdir_path(git_buf **out, git_iterator *i) { - filesystem_iterator *iter = (filesystem_iterator *)i; + filesystem_iterator *iter = GIT_CONTAINER_OF(i, filesystem_iterator, base); const git_index_entry *entry; if (i->type != GIT_ITERATOR_TYPE_FS && @@ -1724,15 +1724,19 @@ GIT_INLINE(bool) filesystem_iterator_current_is_ignored( bool git_iterator_current_is_ignored(git_iterator *i) { + filesystem_iterator *iter = NULL; + if (i->type != GIT_ITERATOR_TYPE_WORKDIR) return false; - return filesystem_iterator_current_is_ignored((filesystem_iterator *)i); + iter = GIT_CONTAINER_OF(i, filesystem_iterator, base); + + return filesystem_iterator_current_is_ignored(iter); } bool git_iterator_current_tree_is_ignored(git_iterator *i) { - filesystem_iterator *iter = (filesystem_iterator *)i; + filesystem_iterator *iter = GIT_CONTAINER_OF(i, filesystem_iterator, base); filesystem_iterator_frame *frame; if (i->type != GIT_ITERATOR_TYPE_WORKDIR) @@ -1747,7 +1751,7 @@ static int filesystem_iterator_advance_over( git_iterator_status_t *status, git_iterator *i) { - filesystem_iterator *iter = (filesystem_iterator *)i; + filesystem_iterator *iter = GIT_CONTAINER_OF(i, filesystem_iterator, base); filesystem_iterator_frame *current_frame; filesystem_iterator_entry *current_entry; const git_index_entry *entry = NULL; @@ -1866,7 +1870,7 @@ static int filesystem_iterator_init(filesystem_iterator *iter) static int filesystem_iterator_reset(git_iterator *i) { - filesystem_iterator *iter = (filesystem_iterator *)i; + filesystem_iterator *iter = GIT_CONTAINER_OF(i, filesystem_iterator, base); filesystem_iterator_clear(iter); return filesystem_iterator_init(iter); @@ -1874,7 +1878,7 @@ static int filesystem_iterator_reset(git_iterator *i) static void filesystem_iterator_free(git_iterator *i) { - filesystem_iterator *iter = (filesystem_iterator *)i; + filesystem_iterator *iter = GIT_CONTAINER_OF(i, filesystem_iterator, base); git__free(iter->root); git_buf_dispose(&iter->current_path); git_tree_free(iter->tree); @@ -2083,7 +2087,7 @@ static int index_iterator_skip_pseudotree(index_iterator *iter) static int index_iterator_advance( const git_index_entry **out, git_iterator *i) { - index_iterator *iter = (index_iterator *)i; + index_iterator *iter = GIT_CONTAINER_OF(i, index_iterator, base); const git_index_entry *entry = NULL; bool is_submodule; int error = 0; @@ -2156,7 +2160,7 @@ static int index_iterator_advance( static int index_iterator_advance_into( const git_index_entry **out, git_iterator *i) { - index_iterator *iter = (index_iterator *)i; + index_iterator *iter = GIT_CONTAINER_OF(i, index_iterator, base); if (! S_ISDIR(iter->tree_entry.mode)) { if (out) @@ -2174,7 +2178,7 @@ static int index_iterator_advance_over( git_iterator_status_t *status, git_iterator *i) { - index_iterator *iter = (index_iterator *)i; + index_iterator *iter = GIT_CONTAINER_OF(i, index_iterator, base); const git_index_entry *entry; int error; @@ -2203,7 +2207,7 @@ static int index_iterator_init(index_iterator *iter) static int index_iterator_reset(git_iterator *i) { - index_iterator *iter = (index_iterator *)i; + index_iterator *iter = GIT_CONTAINER_OF(i, index_iterator, base); index_iterator_clear(iter); return index_iterator_init(iter); @@ -2211,7 +2215,7 @@ static int index_iterator_reset(git_iterator *i) static void index_iterator_free(git_iterator *i) { - index_iterator *iter = (index_iterator *)i; + index_iterator *iter = GIT_CONTAINER_OF(i, index_iterator, base); git_index_snapshot_release(&iter->entries, iter->base.index); git_buf_dispose(&iter->tree_buf); |