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
829555a9
Commit
829555a9
authored
Aug 02, 2022
by
yuangli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edit tests for shallow clones
parent
8ef492fa
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
10 deletions
+38
-10
tests/libgit2/clone/shallow.c
+38
-10
No files found.
tests/libgit2/clone/shallow.c
View file @
829555a9
...
...
@@ -22,6 +22,32 @@ static int remote_single_branch(git_remote **out, git_repository *repo, const ch
return
0
;
}
void
test_clone_shallow__clone_depth_zero
(
void
)
{
git_str
path
=
GIT_STR_INIT
;
git_repository
*
repo
;
git_clone_options
clone_opts
=
GIT_CLONE_OPTIONS_INIT
;
git_array_oid_t
roots
=
GIT_ARRAY_INIT
;
clone_opts
.
fetch_opts
.
depth
=
0
;
clone_opts
.
remote_cb
=
remote_single_branch
;
git_str_joinpath
(
&
path
,
clar_sandbox_path
(),
"shallowclone_0"
);
cl_git_pass
(
git_clone
(
&
repo
,
"https://github.com/libgit2/TestGitRepository"
,
git_str_cstr
(
&
path
),
&
clone_opts
));
/* cloning with depth 0 results in a full clone. */
cl_assert_equal_b
(
false
,
git_repository_is_shallow
(
repo
));
/* full clones do not have shallow roots. */
cl_git_pass
(
git_repository__shallow_roots
(
&
roots
,
repo
));
cl_assert_equal_i
(
0
,
roots
.
size
);
git_array_clear
(
roots
);
git_str_dispose
(
&
path
);
git_repository_free
(
repo
);
}
void
test_clone_shallow__clone_depth_one
(
void
)
{
git_str
path
=
GIT_STR_INIT
;
...
...
@@ -29,7 +55,7 @@ void test_clone_shallow__clone_depth_one(void)
git_revwalk
*
walk
;
git_clone_options
clone_opts
=
GIT_CLONE_OPTIONS_INIT
;
git_oid
oid
;
git_
oidarray
roots
;
git_
array_oid_t
roots
=
GIT_ARRAY_INIT
;
size_t
num_commits
=
0
;
int
error
=
0
;
...
...
@@ -42,9 +68,9 @@ void test_clone_shallow__clone_depth_one(void)
cl_assert_equal_b
(
true
,
git_repository_is_shallow
(
repo
));
cl_git_pass
(
git_repository_shallow_roots
(
&
roots
,
repo
));
cl_assert_equal_i
(
1
,
roots
.
count
);
cl_assert_equal_s
(
"49322bb17d3acc9146f98c97d078513228bbf3c0"
,
git_oid_tostr_s
(
&
roots
.
ids
[
0
]));
cl_git_pass
(
git_repository_
_
shallow_roots
(
&
roots
,
repo
));
cl_assert_equal_i
(
1
,
roots
.
size
);
cl_assert_equal_s
(
"49322bb17d3acc9146f98c97d078513228bbf3c0"
,
git_oid_tostr_s
(
&
roots
.
ptr
[
0
]));
git_revwalk_new
(
&
walk
,
repo
);
...
...
@@ -57,6 +83,7 @@ void test_clone_shallow__clone_depth_one(void)
cl_assert_equal_i
(
num_commits
,
1
);
cl_assert_equal_i
(
error
,
GIT_ITEROVER
);
git_array_clear
(
roots
);
git_str_dispose
(
&
path
);
git_revwalk_free
(
walk
);
git_repository_free
(
repo
);
...
...
@@ -69,7 +96,7 @@ void test_clone_shallow__clone_depth_five(void)
git_revwalk
*
walk
;
git_clone_options
clone_opts
=
GIT_CLONE_OPTIONS_INIT
;
git_oid
oid
;
git_
oidarray
roots
;
git_
array_oid_t
roots
=
GIT_ARRAY_INIT
;
size_t
num_commits
=
0
;
int
error
=
0
;
...
...
@@ -82,11 +109,11 @@ void test_clone_shallow__clone_depth_five(void)
cl_assert_equal_b
(
true
,
git_repository_is_shallow
(
repo
));
cl_git_pass
(
git_repository_shallow_roots
(
&
roots
,
repo
));
cl_assert_equal_i
(
3
,
roots
.
count
);
cl_assert_equal_s
(
"c070ad8c08840c8116da865b2d65593a6bb9cd2a"
,
git_oid_tostr_s
(
&
roots
.
ids
[
0
]));
cl_assert_equal_s
(
"0966a434eb1a025db6b71485ab63a3bfbea520b6"
,
git_oid_tostr_s
(
&
roots
.
ids
[
1
]));
cl_assert_equal_s
(
"83834a7afdaa1a1260568567f6ad90020389f664"
,
git_oid_tostr_s
(
&
roots
.
ids
[
2
]));
cl_git_pass
(
git_repository_
_
shallow_roots
(
&
roots
,
repo
));
cl_assert_equal_i
(
3
,
roots
.
size
);
cl_assert_equal_s
(
"c070ad8c08840c8116da865b2d65593a6bb9cd2a"
,
git_oid_tostr_s
(
&
roots
.
ptr
[
0
]));
cl_assert_equal_s
(
"0966a434eb1a025db6b71485ab63a3bfbea520b6"
,
git_oid_tostr_s
(
&
roots
.
ptr
[
1
]));
cl_assert_equal_s
(
"83834a7afdaa1a1260568567f6ad90020389f664"
,
git_oid_tostr_s
(
&
roots
.
ptr
[
2
]));
git_revwalk_new
(
&
walk
,
repo
);
...
...
@@ -99,6 +126,7 @@ void test_clone_shallow__clone_depth_five(void)
cl_assert_equal_i
(
num_commits
,
13
);
cl_assert_equal_i
(
error
,
GIT_ITEROVER
);
git_array_clear
(
roots
);
git_str_dispose
(
&
path
);
git_revwalk_free
(
walk
);
git_repository_free
(
repo
);
...
...
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