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
10df95c3
Commit
10df95c3
authored
Sep 15, 2012
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
checkout: add test coverage of dirs and subtrees
parent
5af61863
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
6 deletions
+46
-6
tests-clar/checkout/tree.c
+46
-6
No files found.
tests-clar/checkout/tree.c
View file @
10df95c3
...
...
@@ -4,26 +4,66 @@
#include "repository.h"
static
git_repository
*
g_repo
;
static
git_checkout_opts
g_opts
;
static
git_object
*
g_object
;
void
test_checkout_tree__initialize
(
void
)
{
g_repo
=
cl_git_sandbox_init
(
"testrepo"
);
memset
(
&
g_opts
,
0
,
sizeof
(
g_opts
));
g_opts
.
checkout_strategy
=
GIT_CHECKOUT_CREATE_MISSING
;
}
void
test_checkout_tree__cleanup
(
void
)
{
git_object_free
(
g_object
);
cl_git_sandbox_cleanup
();
}
void
test_checkout_tree__cannot_checkout_a_non_treeish
(
void
)
{
git_oid
oid
;
git_blob
*
blob
;
/* blob */
cl_git_pass
(
git_revparse_single
(
&
g_object
,
g_repo
,
"a71586c1dfe8a71c6cbf6c129f404c5642ff31bd"
));
cl_git_fail
(
git_checkout_tree
(
g_repo
,
g_object
,
NULL
,
NULL
));
}
void
test_checkout_tree__can_checkout_a_subdirectory_from_a_commit
(
void
)
{
git_strarray
paths
;
char
*
entries
[]
=
{
"ab/de/"
};
paths
.
strings
=
entries
;
paths
.
count
=
1
;
g_opts
.
paths
=
&
paths
;
cl_git_pass
(
git_revparse_single
(
&
g_object
,
g_repo
,
"subtrees"
));
cl_assert_equal_i
(
false
,
git_path_isdir
(
"./testrepo/ab/"
));
cl_git_pass
(
git_checkout_tree
(
g_repo
,
g_object
,
&
g_opts
,
NULL
));
cl_assert_equal_i
(
true
,
git_path_isfile
(
"./testrepo/ab/de/2.txt"
));
cl_assert_equal_i
(
true
,
git_path_isfile
(
"./testrepo/ab/de/fgh/1.txt"
));
}
void
test_checkout_tree__can_checkout_a_subdirectory_from_a_subtree
(
void
)
{
git_strarray
paths
;
char
*
entries
[]
=
{
"de/"
};
paths
.
strings
=
entries
;
paths
.
count
=
1
;
g_opts
.
paths
=
&
paths
;
cl_git_pass
(
git_revparse_single
(
&
g_object
,
g_repo
,
"subtrees:ab"
));
cl_git_pass
(
git_oid_fromstr
(
&
oid
,
"a71586c1dfe8a71c6cbf6c129f404c5642ff31bd"
));
cl_git_pass
(
git_blob_lookup
(
&
blob
,
g_repo
,
&
oid
));
cl_assert_equal_i
(
false
,
git_path_isdir
(
"./testrepo/de/"
));
cl_git_
fail
(
git_checkout_tree
(
g_repo
,
(
git_object
*
)
blob
,
NULL
,
NULL
));
cl_git_
pass
(
git_checkout_tree
(
g_repo
,
g_object
,
&
g_opts
,
NULL
));
git_blob_free
(
blob
);
cl_assert_equal_i
(
true
,
git_path_isfile
(
"./testrepo/de/2.txt"
));
cl_assert_equal_i
(
true
,
git_path_isfile
(
"./testrepo/de/fgh/1.txt"
));
}
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