diff options
author | Marijan Šuflaj <msufflaj32@gmail.com> | 2019-01-20 20:15:31 +0100 |
---|---|---|
committer | Marijan Šuflaj <msufflaj32@gmail.com> | 2019-01-20 20:15:31 +0100 |
commit | f7416509c065b908e6d06ec11b31379b3bc51f90 (patch) | |
tree | b0daceaa7463b5afbfab7930c8dfd82e17c20be3 /tests/odb | |
parent | 68166017dc31164aa9ad610d0d87658ab065a902 (diff) | |
download | libgit2-f7416509c065b908e6d06ec11b31379b3bc51f90.tar.gz |
Fix odb foreach to also close on positive error code
In include/git2/odb.h it states that callback can also return
positive value which should break looping.
Implementations of git_odb_foreach() and pack_backend__foreach()
did not respect that.
Diffstat (limited to 'tests/odb')
-rw-r--r-- | tests/odb/foreach.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/odb/foreach.c b/tests/odb/foreach.c index 3e44f10bb..7a45a57ae 100644 --- a/tests/odb/foreach.c +++ b/tests/odb/foreach.c @@ -81,6 +81,16 @@ static int foreach_stop_first_cb(const git_oid *oid, void *data) return -123; } +static int foreach_stop_cb_positive_ret(const git_oid *oid, void *data) +{ + int *nobj = data; + (*nobj)++; + + GIT_UNUSED(oid); + + return (*nobj == 1000) ? 321 : 0; +} + void test_odb_foreach__interrupt_foreach(void) { int nobj = 0; @@ -92,6 +102,11 @@ void test_odb_foreach__interrupt_foreach(void) cl_assert_equal_i(-321, git_odb_foreach(_odb, foreach_stop_cb, &nobj)); cl_assert(nobj == 1000); + nobj = 0; + + cl_assert_equal_i(321, git_odb_foreach(_odb, foreach_stop_cb_positive_ret, &nobj)); + cl_assert(nobj == 1000); + git_odb_free(_odb); git_repository_free(_repo); |