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
cc4f4cbe
Unverified
Commit
cc4f4cbe
authored
Jan 12, 2020
by
Edward Thomson
Committed by
GitHub
Jan 12, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5355 from pks-t/pks/win32-relative-symlink-across-dirs
win32: fix relative symlinks pointing into dirs
parents
d5482339
7d55bee6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletions
+36
-1
src/win32/posix_w32.c
+9
-1
tests/core/posix.c
+27
-0
No files found.
src/win32/posix_w32.c
View file @
cc4f4cbe
...
...
@@ -439,8 +439,16 @@ int p_symlink(const char *target, const char *path)
git_win32_path
target_w
,
path_w
;
DWORD
dwFlags
;
/*
* Convert both target and path to Windows-style paths. Note that we do
* not want to use `git_win32_path_from_utf8` for converting the target,
* as that function will automatically pre-pend the current working
* directory in case the path is not absolute. As Git will instead use
* relative symlinks, this is not someting we want.
*/
if
(
git_win32_path_from_utf8
(
path_w
,
path
)
<
0
||
git__utf8_to_16
(
target_w
,
MAX_PATH
,
target
)
<
0
)
git__utf8_to_16
(
target_w
,
MAX_PATH
,
target
)
<
0
||
git_win32_path_canonicalize
(
target_w
)
<
0
)
return
-
1
;
dwFlags
=
SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE
;
...
...
tests/core/posix.c
View file @
cc4f4cbe
...
...
@@ -189,3 +189,30 @@ void test_core_posix__symlink_resolves_to_correct_type(void)
git_buf_dispose
(
&
contents
);
}
void
test_core_posix__symlink_to_file_across_dirs
(
void
)
{
git_buf
contents
=
GIT_BUF_INIT
;
if
(
!
git_path_supports_symlinks
(
clar_sandbox_path
()))
clar__skip
();
/*
* Create a relative symlink that points into another
* directory. This used to not work on Win32, where we
* forgot to convert directory separators to
* Windows-style ones.
*/
cl_must_pass
(
git_futils_mkdir
(
"dir"
,
0777
,
0
));
cl_git_mkfile
(
"dir/target"
,
"symlink target"
);
cl_git_pass
(
p_symlink
(
"dir/target"
,
"link"
));
cl_git_pass
(
git_futils_readbuffer
(
&
contents
,
"dir/target"
));
cl_assert_equal_s
(
contents
.
ptr
,
"symlink target"
);
cl_must_pass
(
p_unlink
(
"dir/target"
));
cl_must_pass
(
p_unlink
(
"link"
));
cl_must_pass
(
p_rmdir
(
"dir"
));
git_buf_dispose
(
&
contents
);
}
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