Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
932af0e9
Commit
932af0e9
authored
May 04, 2013
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add iterator support to the testdb backend
parent
fb592a96
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
+46
-0
tests-clar/refdb/testdb.c
+46
-0
No files found.
tests-clar/refdb/testdb.c
View file @
932af0e9
...
@@ -112,6 +112,49 @@ static int refdb_test_backend__lookup(
...
@@ -112,6 +112,49 @@ static int refdb_test_backend__lookup(
return
GIT_ENOTFOUND
;
return
GIT_ENOTFOUND
;
}
}
typedef
struct
{
git_reference_iterator
parent
;
size_t
i
;
}
refdb_test_iter
;
static
int
refdb_test_backend__iterator
(
git_reference_iterator
**
out
,
git_refdb_backend
*
_backend
)
{
refdb_test_iter
*
iter
;
GIT_UNUSED
(
_backend
);
iter
=
git__malloc
(
sizeof
(
refdb_test_iter
));
GITERR_CHECK_ALLOC
(
iter
);
iter
->
parent
.
backend
=
_backend
;
iter
->
i
=
0
;
*
out
=
(
git_reference_iterator
*
)
iter
;
return
0
;
}
static
int
refdb_test_backend__next
(
const
char
**
name
,
git_reference_iterator
*
_iter
)
{
refdb_test_entry
*
entry
;
refdb_test_backend
*
backend
=
(
refdb_test_backend
*
)
_iter
->
backend
;
refdb_test_iter
*
iter
=
(
refdb_test_iter
*
)
_iter
;
entry
=
git_vector_get
(
&
backend
->
refs
,
iter
->
i
);
if
(
!
entry
)
return
GIT_ITEROVER
;
*
name
=
entry
->
name
;
iter
->
i
++
;
return
0
;
}
static
void
refdb_test_backend__iterator_free
(
git_reference_iterator
*
iter
)
{
git__free
(
iter
);
}
static
int
refdb_test_backend__foreach
(
static
int
refdb_test_backend__foreach
(
git_refdb_backend
*
_backend
,
git_refdb_backend
*
_backend
,
unsigned
int
list_flags
,
unsigned
int
list_flags
,
...
@@ -200,6 +243,9 @@ int refdb_backend_test(
...
@@ -200,6 +243,9 @@ int refdb_backend_test(
backend
->
parent
.
exists
=
&
refdb_test_backend__exists
;
backend
->
parent
.
exists
=
&
refdb_test_backend__exists
;
backend
->
parent
.
lookup
=
&
refdb_test_backend__lookup
;
backend
->
parent
.
lookup
=
&
refdb_test_backend__lookup
;
backend
->
parent
.
iterator
=
&
refdb_test_backend__iterator
;
backend
->
parent
.
next
=
&
refdb_test_backend__next
;
backend
->
parent
.
iterator_free
=
&
refdb_test_backend__iterator_free
;
backend
->
parent
.
foreach
=
&
refdb_test_backend__foreach
;
backend
->
parent
.
foreach
=
&
refdb_test_backend__foreach
;
backend
->
parent
.
write
=
&
refdb_test_backend__write
;
backend
->
parent
.
write
=
&
refdb_test_backend__write
;
backend
->
parent
.
delete
=
&
refdb_test_backend__delete
;
backend
->
parent
.
delete
=
&
refdb_test_backend__delete
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment