summaryrefslogtreecommitdiff
path: root/tests/revwalk
diff options
context:
space:
mode:
authorEivind Fonn <evfonn@gmail.com>2018-11-14 16:08:30 +0100
committerEivind Fonn <evfonn@gmail.com>2018-11-28 14:19:48 +0100
commit0836f0695ec1cb5ec45372bd3c7696bbd65cf8b7 (patch)
tree6a721e84e490ad59c3fb42b54e4b44fd92efa019 /tests/revwalk
parent9189a66a9eb99f13ee81da5913ade3a1ff64262a (diff)
downloadlibgit2-0836f0695ec1cb5ec45372bd3c7696bbd65cf8b7.tar.gz
revwalk: Allow changing hide_cb
Since git_revwalk objects are encouraged to be reused, a public interface for changing hide_cb is desirable.
Diffstat (limited to 'tests/revwalk')
-rw-r--r--tests/revwalk/hidecb.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/tests/revwalk/hidecb.c b/tests/revwalk/hidecb.c
index b274ed86a..54315bc77 100644
--- a/tests/revwalk/hidecb.c
+++ b/tests/revwalk/hidecb.c
@@ -117,13 +117,40 @@ void test_revwalk_hidecb__hide_none_cb(void)
git_revwalk_free(walk);
}
-void test_revwalk_hidecb__add_hide_cb_multiple_times(void)
+void test_revwalk_hidecb__unset_cb_before_walk(void)
{
git_revwalk *walk;
+ git_oid id;
+ int i, error;
+
+ cl_git_pass(git_revwalk_new(&walk, _repo));
+ cl_git_pass(git_revwalk_add_hide_cb(walk, hide_every_commit_cb, NULL));
+ cl_git_pass(git_revwalk_add_hide_cb(walk, NULL, NULL));
+ cl_git_pass(git_revwalk_push(walk, &_head_id));
+
+ /* It should return all 6 commits */
+ i = 0;
+ while ((error = git_revwalk_next(&id, walk)) == 0)
+ i++;
+
+ cl_assert_equal_i(i, 6);
+ cl_assert_equal_i(error, GIT_ITEROVER);
+
+ git_revwalk_free(walk);
+}
+
+void test_revwalk_hidecb__change_cb_before_walk(void)
+{
+ git_revwalk *walk;
+ git_oid id;
cl_git_pass(git_revwalk_new(&walk, _repo));
+ cl_git_pass(git_revwalk_add_hide_cb(walk, hide_none_cb, NULL));
cl_git_pass(git_revwalk_add_hide_cb(walk, hide_every_commit_cb, NULL));
- cl_git_fail(git_revwalk_add_hide_cb(walk, hide_every_commit_cb, NULL));
+ cl_git_pass(git_revwalk_push(walk, &_head_id));
+
+ /* First call to git_revwalk_next should return GIT_ITEROVER */
+ cl_assert_equal_i(GIT_ITEROVER, git_revwalk_next(&id, walk));
git_revwalk_free(walk);
}