diff options
author | Russell Belfer <rb@github.com> | 2013-07-22 22:01:19 +0400 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-07-22 22:01:19 +0400 |
commit | b71071313f4800840ecc48cb18e5cedec8ef250e (patch) | |
tree | 4a565ee90a594ba18ad9e52f38edfffb1366c7fd /tests-clar/revwalk | |
parent | 1cd9dc29b7105cb33959d15ab670a085f5a1445b (diff) |
git_reference_next_name must match git_reference_next
The git_reference_next API silently skips invalid references when
scanning the loose refs. The git_reference_next_name API should
skip the same ones even though it isn't creating the reference
object.
This adds a test with a an invalid loose reference and makes sure
that both APIs skip the same entries and generate the same results.
Diffstat (limited to 'tests-clar/revwalk')
-rw-r--r-- | tests-clar/revwalk/basic.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests-clar/revwalk/basic.c b/tests-clar/revwalk/basic.c index e82776260..7c2fc000d 100644 --- a/tests-clar/revwalk/basic.c +++ b/tests-clar/revwalk/basic.c @@ -142,6 +142,28 @@ void test_revwalk_basic__glob_heads(void) cl_assert(i == 14); } +void test_revwalk_basic__glob_heads_with_invalid(void) +{ + int i; + git_oid oid; + + test_revwalk_basic__cleanup(); + + _repo = cl_git_sandbox_init("testrepo"); + cl_git_mkfile("testrepo/.git/refs/heads/garbage", "not-a-ref"); + + cl_git_pass(git_revwalk_new(&_walk, _repo)); + cl_git_pass(git_revwalk_push_glob(_walk, "heads")); + + for (i = 0; !git_revwalk_next(&oid, _walk); ++i) + /* walking */; + + /* git log --branches --oneline | wc -l => 16 */ + cl_assert_equal_i(16, i); + + cl_fixture_cleanup("testrepo"); +} + void test_revwalk_basic__push_head(void) { int i = 0; |