diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2012-11-29 08:43:55 +0400 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2012-12-04 00:51:39 +0400 |
commit | b2414661332f7fd6a6819395f1505a58f8d75b5e (patch) | |
tree | 6977dbd65d3b29cc2c8dd2747cc4c457f09079e1 /src/iterator.c | |
parent | 3368c520dcd345cbc404afe9da68f4c8c3035981 (diff) |
status should ignore conflicts entries in the index
Diffstat (limited to 'src/iterator.c')
-rw-r--r-- | src/iterator.c | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/src/iterator.c b/src/iterator.c index bd586ce99..0fdf0c69d 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -340,14 +340,6 @@ static int index_iterator__current( index_iterator *ii = (index_iterator *)self; const git_index_entry *ie = git_index_get_byindex(ii->index, ii->current); - if (ie != NULL && - ii->base.end != NULL && - ITERATOR_PREFIXCMP(ii->base, ie->path, ii->base.end) > 0) - { - ii->current = git_index_entrycount(ii->index); - ie = NULL; - } - if (entry) *entry = ie; @@ -360,6 +352,29 @@ static int index_iterator__at_end(git_iterator *self) return (ii->current >= git_index_entrycount(ii->index)); } +static void index_iterator__skip_conflicts( + index_iterator *ii) +{ + size_t entrycount = git_index_entrycount(ii->index); + const git_index_entry *ie; + + while (ii->current < entrycount) { + ie = git_index_get_byindex(ii->index, ii->current); + + if (ie == NULL || + (ii->base.end != NULL && + ITERATOR_PREFIXCMP(ii->base, ie->path, ii->base.end) > 0)) { + ii->current = entrycount; + break; + } + + if (git_index_entry_stage(ie) == 0) + break; + + ii->current++; + } +} + static int index_iterator__advance( git_iterator *self, const git_index_entry **entry) { @@ -368,6 +383,8 @@ static int index_iterator__advance( if (ii->current < git_index_entrycount(ii->index)) ii->current++; + index_iterator__skip_conflicts(ii); + return index_iterator__current(self, entry); } @@ -382,7 +399,9 @@ static int index_iterator__seek(git_iterator *self, const char *prefix) static int index_iterator__reset(git_iterator *self) { index_iterator *ii = (index_iterator *)self; - ii->current = 0; + ii->current = ii->base.start ? + git_index__prefix_position(ii->index, ii->base.start) : 0; + index_iterator__skip_conflicts(ii); return 0; } @@ -406,7 +425,8 @@ int git_iterator_for_index_range( ii->index = index; ii->base.ignore_case = ii->index->ignore_case; - ii->current = start ? git_index__prefix_position(ii->index, start) : 0; + + index_iterator__reset((git_iterator *)ii); *iter = (git_iterator *)ii; |