Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-05-11 17:42:25 +0400
committerRussell Belfer <rb@github.com>2013-05-11 17:42:25 +0400
commit99d32707b963e6fea16817cafd5c3f579578a262 (patch)
tree3596036b3570e8c8784cfe5ebb4d496631c5e33c /src/refdb_fs.c
parent7b5bc8f498cd4f05f8580d848c03188dc5b06811 (diff)
Fix refdb iteration early termination bug
There was a problem found in the Rugged test suite where the refdb_fs_backend__next function could exit too early in some very specific hashing patterns for packed refs. This ports the Rugged test to libgit2 and then fixes the bug.
Diffstat (limited to 'src/refdb_fs.c')
-rw-r--r--src/refdb_fs.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/refdb_fs.c b/src/refdb_fs.c
index 9d0af579e..c462a4251 100644
--- a/src/refdb_fs.c
+++ b/src/refdb_fs.c
@@ -671,17 +671,20 @@ static int refdb_fs_backend__next(const char **out, git_reference_iterator *_ite
{
refdb_fs_iter *iter = (refdb_fs_iter *)_iter;
- /* First round of checks to make sure where we are */
- if (!iter->loose && iter->k == kh_end(iter->h)) {
- if (iter_loose_setup(iter) < 0)
- return -1;
- iter->loose = 1;
+ if (iter->loose)
+ return iter_loose(out, iter);
+
+ if (iter->k != kh_end(iter->h)) {
+ int error = iter_packed(out, iter);
+ if (error != GIT_ITEROVER)
+ return error;
}
- if (!iter->loose)
- return iter_packed(out, iter);
- else
- return iter_loose(out, iter);
+ if (iter_loose_setup(iter) < 0)
+ return -1;
+ iter->loose = 1;
+
+ return iter_loose(out, iter);
}
static int loose_write(refdb_fs_backend *backend, const git_reference *ref)