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
628dae8b
Commit
628dae8b
authored
Oct 19, 2018
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: provide symlink support helper function
parent
df1733de
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
30 deletions
+17
-30
tests/checkout/index.c
+3
-22
tests/repo/init.c
+1
-8
tests/repo/repo_helpers.c
+12
-0
tests/repo/repo_helpers.h
+1
-0
No files found.
tests/checkout/index.c
View file @
628dae8b
...
@@ -136,25 +136,6 @@ void test_checkout_index__honor_coreautocrlf_setting_set_to_true(void)
...
@@ -136,25 +136,6 @@ void test_checkout_index__honor_coreautocrlf_setting_set_to_true(void)
#endif
#endif
}
}
static
bool
supports_symlinks
(
const
char
*
dir
)
{
git_buf
path
=
GIT_BUF_INIT
;
struct
stat
st
;
bool
supports_symlinks
=
1
;
cl_git_pass
(
git_buf_joinpath
(
&
path
,
dir
,
"test"
));
/* see if symlinks are supported in the "symlink" directory */
if
(
p_symlink
(
"target"
,
path
.
ptr
)
<
0
||
p_lstat
(
path
.
ptr
,
&
st
)
<
0
||
!
(
S_ISLNK
(
st
.
st_mode
)))
supports_symlinks
=
0
;
git_buf_dispose
(
&
path
);
return
supports_symlinks
;
}
void
test_checkout_index__honor_coresymlinks_default
(
void
)
void
test_checkout_index__honor_coresymlinks_default
(
void
)
{
{
git_repository
*
repo
;
git_repository
*
repo
;
...
@@ -181,7 +162,7 @@ void test_checkout_index__honor_coresymlinks_default(void)
...
@@ -181,7 +162,7 @@ void test_checkout_index__honor_coresymlinks_default(void)
git_object_free
(
target
);
git_object_free
(
target
);
git_repository_free
(
repo
);
git_repository_free
(
repo
);
if
(
!
supports_symlinks
(
"symlink
"
))
{
if
(
!
filesystem_supports_symlinks
(
"symlink/test
"
))
{
check_file_contents
(
"./symlink/link_to_new.txt"
,
"new.txt"
);
check_file_contents
(
"./symlink/link_to_new.txt"
,
"new.txt"
);
}
else
{
}
else
{
char
link_data
[
1024
];
char
link_data
[
1024
];
...
@@ -203,7 +184,7 @@ void test_checkout_index__coresymlinks_set_to_true_fails_when_unsupported(void)
...
@@ -203,7 +184,7 @@ void test_checkout_index__coresymlinks_set_to_true_fails_when_unsupported(void)
{
{
git_checkout_options
opts
=
GIT_CHECKOUT_OPTIONS_INIT
;
git_checkout_options
opts
=
GIT_CHECKOUT_OPTIONS_INIT
;
if
(
supports_symlinks
(
"testrepo
"
))
{
if
(
filesystem_supports_symlinks
(
"testrepo/test
"
))
{
cl_skip
();
cl_skip
();
}
}
...
@@ -219,7 +200,7 @@ void test_checkout_index__honor_coresymlinks_setting_set_to_true(void)
...
@@ -219,7 +200,7 @@ void test_checkout_index__honor_coresymlinks_setting_set_to_true(void)
char
link_data
[
GIT_PATH_MAX
];
char
link_data
[
GIT_PATH_MAX
];
size_t
link_size
=
GIT_PATH_MAX
;
size_t
link_size
=
GIT_PATH_MAX
;
if
(
!
supports_symlinks
(
"testrepo
"
))
{
if
(
!
filesystem_supports_symlinks
(
"testrepo/test
"
))
{
cl_skip
();
cl_skip
();
}
}
...
...
tests/repo/init.c
View file @
628dae8b
...
@@ -249,15 +249,8 @@ void test_repo_init__detect_ignorecase(void)
...
@@ -249,15 +249,8 @@ void test_repo_init__detect_ignorecase(void)
void
test_repo_init__detect_symlinks
(
void
)
void
test_repo_init__detect_symlinks
(
void
)
{
{
struct
stat
st
;
bool
no_symlinks
;
no_symlinks
=
(
p_symlink
(
"target"
,
"link"
)
<
0
||
p_lstat
(
"link"
,
&
st
)
<
0
||
!
(
S_ISLNK
(
st
.
st_mode
)));
assert_config_entry_on_init
(
assert_config_entry_on_init
(
"core.symlinks"
,
no_symlinks
?
false
:
GIT_ENOTFOUND
);
"core.symlinks"
,
filesystem_supports_symlinks
(
"link"
)
?
GIT_ENOTFOUND
:
false
);
}
}
void
test_repo_init__detect_precompose_unicode_required
(
void
)
void
test_repo_init__detect_precompose_unicode_required
(
void
)
...
...
tests/repo/repo_helpers.c
View file @
628dae8b
...
@@ -20,3 +20,15 @@ void delete_head(git_repository* repo)
...
@@ -20,3 +20,15 @@ void delete_head(git_repository* repo)
git_buf_dispose
(
&
head_path
);
git_buf_dispose
(
&
head_path
);
}
}
int
filesystem_supports_symlinks
(
const
char
*
path
)
{
struct
stat
st
;
if
(
p_symlink
(
"target"
,
path
)
<
0
||
p_lstat
(
path
,
&
st
)
<
0
||
!
(
S_ISLNK
(
st
.
st_mode
)))
return
0
;
return
1
;
}
tests/repo/repo_helpers.h
View file @
628dae8b
...
@@ -4,3 +4,4 @@
...
@@ -4,3 +4,4 @@
extern
void
make_head_unborn
(
git_repository
*
repo
,
const
char
*
target
);
extern
void
make_head_unborn
(
git_repository
*
repo
,
const
char
*
target
);
extern
void
delete_head
(
git_repository
*
repo
);
extern
void
delete_head
(
git_repository
*
repo
);
extern
int
filesystem_supports_symlinks
(
const
char
*
path
);
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