Commit aa3af01d by Edward Thomson

index iterator: optionally include conflicts

parent c7f94123
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#define iterator__include_trees(I) iterator__flag(I,INCLUDE_TREES) #define iterator__include_trees(I) iterator__flag(I,INCLUDE_TREES)
#define iterator__dont_autoexpand(I) iterator__flag(I,DONT_AUTOEXPAND) #define iterator__dont_autoexpand(I) iterator__flag(I,DONT_AUTOEXPAND)
#define iterator__do_autoexpand(I) !iterator__flag(I,DONT_AUTOEXPAND) #define iterator__do_autoexpand(I) !iterator__flag(I,DONT_AUTOEXPAND)
#define iterator__include_conflicts(I) iterator__flag(I, INCLUDE_CONFLICTS)
#define GIT_ITERATOR_FIRST_ACCESS (1 << 15) #define GIT_ITERATOR_FIRST_ACCESS (1 << 15)
#define iterator__has_been_accessed(I) iterator__flag(I,FIRST_ACCESS) #define iterator__has_been_accessed(I) iterator__flag(I,FIRST_ACCESS)
...@@ -668,13 +669,16 @@ static const git_index_entry *index_iterator__index_entry(index_iterator *ii) ...@@ -668,13 +669,16 @@ static const git_index_entry *index_iterator__index_entry(index_iterator *ii)
return ie; return ie;
} }
static const git_index_entry *index_iterator__skip_conflicts(index_iterator *ii) static const git_index_entry *index_iterator__advance_over_conflicts(index_iterator *ii)
{ {
const git_index_entry *ie; const git_index_entry *ie = index_iterator__index_entry(ii);
while ((ie = index_iterator__index_entry(ii)) != NULL && if (!iterator__include_conflicts(ii)) {
git_index_entry_stage(ie) != 0) while (ie && git_index_entry_stage(ie) != 0) {
ii->current++; ii->current++;
ie = index_iterator__index_entry(ii);
}
}
return ie; return ie;
} }
...@@ -702,7 +706,7 @@ static void index_iterator__next_prefix_tree(index_iterator *ii) ...@@ -702,7 +706,7 @@ static void index_iterator__next_prefix_tree(index_iterator *ii)
static int index_iterator__first_prefix_tree(index_iterator *ii) static int index_iterator__first_prefix_tree(index_iterator *ii)
{ {
const git_index_entry *ie = index_iterator__skip_conflicts(ii); const git_index_entry *ie = index_iterator__advance_over_conflicts(ii);
const char *scan, *prior, *slash; const char *scan, *prior, *slash;
if (!ie || !iterator__include_trees(ii)) if (!ie || !iterator__include_trees(ii))
...@@ -825,7 +829,7 @@ static int index_iterator__reset( ...@@ -825,7 +829,7 @@ static int index_iterator__reset(
git_index_snapshot_find( git_index_snapshot_find(
&ii->current, &ii->entries, ii->entry_srch, ii->base.start, 0, 0); &ii->current, &ii->entries, ii->entry_srch, ii->base.start, 0, 0);
if ((ie = index_iterator__skip_conflicts(ii)) == NULL) if ((ie = index_iterator__advance_over_conflicts(ii)) == NULL)
return 0; return 0;
if (git_buf_sets(&ii->partial, ie->path) < 0) if (git_buf_sets(&ii->partial, ie->path) < 0)
......
...@@ -33,6 +33,8 @@ typedef enum { ...@@ -33,6 +33,8 @@ typedef enum {
GIT_ITERATOR_DONT_AUTOEXPAND = (1u << 3), GIT_ITERATOR_DONT_AUTOEXPAND = (1u << 3),
/** convert precomposed unicode to decomposed unicode */ /** convert precomposed unicode to decomposed unicode */
GIT_ITERATOR_PRECOMPOSE_UNICODE = (1u << 4), GIT_ITERATOR_PRECOMPOSE_UNICODE = (1u << 4),
/** include conflicts */
GIT_ITERATOR_INCLUDE_CONFLICTS = (1u << 5),
} git_iterator_flag_t; } git_iterator_flag_t;
typedef struct { typedef struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment