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
e580afd8
Commit
e580afd8
authored
Sep 13, 2013
by
Russell Belfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for git_tree_walk
This tests the fixes for issues from #1849
parent
236945a5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
0 deletions
+74
-0
tests-clar/object/tree/walk.c
+74
-0
No files found.
tests-clar/object/tree/walk.c
View file @
e580afd8
...
@@ -101,3 +101,77 @@ void test_object_tree_walk__1(void)
...
@@ -101,3 +101,77 @@ void test_object_tree_walk__1(void)
git_tree_free
(
tree
);
git_tree_free
(
tree
);
}
}
struct
treewalk_skip_data
{
int
files
;
int
dirs
;
const
char
*
skip
;
const
char
*
stop
;
};
static
int
treewalk_skip_de_cb
(
const
char
*
root
,
const
git_tree_entry
*
entry
,
void
*
payload
)
{
struct
treewalk_skip_data
*
data
=
payload
;
const
char
*
name
=
git_tree_entry_name
(
entry
);
GIT_UNUSED
(
root
);
if
(
git_tree_entry_type
(
entry
)
==
GIT_OBJ_TREE
)
data
->
dirs
++
;
else
data
->
files
++
;
if
(
data
->
skip
&&
!
strcmp
(
name
,
data
->
skip
))
return
1
;
else
if
(
data
->
stop
&&
!
strcmp
(
name
,
data
->
stop
))
return
-
1
;
else
return
0
;
}
void
test_object_tree_walk__2
(
void
)
{
git_oid
id
;
git_tree
*
tree
;
struct
treewalk_skip_data
data
;
/* look up a deep tree */
git_oid_fromstr
(
&
id
,
"ae90f12eea699729ed24555e40b9fd669da12a12"
);
cl_git_pass
(
git_tree_lookup
(
&
tree
,
g_repo
,
&
id
));
memset
(
&
data
,
0
,
sizeof
(
data
));
data
.
skip
=
"de"
;
cl_assert_equal_i
(
0
,
git_tree_walk
(
tree
,
GIT_TREEWALK_PRE
,
treewalk_skip_de_cb
,
&
data
));
cl_assert_equal_i
(
5
,
data
.
files
);
cl_assert_equal_i
(
3
,
data
.
dirs
);
memset
(
&
data
,
0
,
sizeof
(
data
));
data
.
stop
=
"3.txt"
;
cl_assert_equal_i
(
GIT_EUSER
,
git_tree_walk
(
tree
,
GIT_TREEWALK_PRE
,
treewalk_skip_de_cb
,
&
data
));
cl_assert_equal_i
(
3
,
data
.
files
);
cl_assert_equal_i
(
2
,
data
.
dirs
);
memset
(
&
data
,
0
,
sizeof
(
data
));
data
.
skip
=
"new.txt"
;
cl_assert_equal_i
(
0
,
git_tree_walk
(
tree
,
GIT_TREEWALK_PRE
,
treewalk_skip_de_cb
,
&
data
));
cl_assert_equal_i
(
7
,
data
.
files
);
cl_assert_equal_i
(
4
,
data
.
dirs
);
memset
(
&
data
,
0
,
sizeof
(
data
));
data
.
stop
=
"new.txt"
;
cl_assert_equal_i
(
GIT_EUSER
,
git_tree_walk
(
tree
,
GIT_TREEWALK_PRE
,
treewalk_skip_de_cb
,
&
data
));
cl_assert_equal_i
(
7
,
data
.
files
);
cl_assert_equal_i
(
4
,
data
.
dirs
);
git_tree_free
(
tree
);
}
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