diff options
author | Russell Belfer <arrbee@arrbee.com> | 2012-02-22 11:22:33 -0800 |
---|---|---|
committer | Russell Belfer <arrbee@arrbee.com> | 2012-02-22 11:22:33 -0800 |
commit | da337c806468d2d8a27dfa9ee5e75e476f5ad546 (patch) | |
tree | 74a4d71539163c32ccc019eb0d5d8d6082f168af /tests-clar/diff/iterator.c | |
parent | b6c93aef4276051f9c4536ecbed48f4cd093bd1b (diff) | |
download | libgit2-da337c806468d2d8a27dfa9ee5e75e476f5ad546.tar.gz |
Iterator improvements from diff implementation
This makes two changes to iterator behavior: first, advance
can optionally do the work of returning the new current value.
This is such a common pattern that it really cleans up usage.
Second, for workdir iterators, this removes automatically
iterating into directories. That seemed like a good idea,
but when an entirely new directory hierarchy is introduced
into the workdir, there is no reason to iterate into it if
there are no corresponding entries in the tree/index that it
is being compared to.
This second change actually wasn't a lot of code because not
descending into directories was already the behavior for
ignored directories. This just extends that to all directories.
Diffstat (limited to 'tests-clar/diff/iterator.c')
-rw-r--r-- | tests-clar/diff/iterator.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tests-clar/diff/iterator.c b/tests-clar/diff/iterator.c index e13e3e2bb..46f8f59fb 100644 --- a/tests-clar/diff/iterator.c +++ b/tests-clar/diff/iterator.c @@ -73,8 +73,7 @@ static void tree_iterator_test( count++; - cl_git_pass(git_iterator_advance(i)); - cl_git_pass(git_iterator_current(i, &entry)); + cl_git_pass(git_iterator_advance(i, &entry)); } git_iterator_free(i); @@ -201,8 +200,7 @@ static void index_iterator_test( } count++; - cl_git_pass(git_iterator_advance(i)); - cl_git_pass(git_iterator_current(i, &entry)); + cl_git_pass(git_iterator_advance(i, &entry)); } git_iterator_free(i); @@ -314,6 +312,11 @@ static void workdir_iterator_test( while (entry != NULL) { int ignored = git_iterator_current_is_ignored(i); + if (!ignored && S_ISDIR(entry->mode)) { + cl_git_pass(git_iterator_advance_into_directory(i, &entry)); + continue; + } + if (expected_names != NULL) cl_assert_strequal(expected_names[count_all], entry->path); @@ -324,8 +327,7 @@ static void workdir_iterator_test( count++; count_all++; - cl_git_pass(git_iterator_advance(i)); - cl_git_pass(git_iterator_current(i, &entry)); + cl_git_pass(git_iterator_advance(i, &entry)); } git_iterator_free(i); |