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
f92d495d
Unverified
Commit
f92d495d
authored
Jul 12, 2019
by
Patrick Steinhardt
Committed by
GitHub
Jul 12, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5131 from pks-t/pks/fileops-mkdir-in-root
fileops: fix creation of directory in filesystem root
parents
dacac9e1
5ae22a63
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
3 deletions
+46
-3
src/fileops.c
+3
-1
tests/repo/init.c
+43
-2
No files found.
src/fileops.c
View file @
f92d495d
...
...
@@ -495,7 +495,9 @@ int git_futils_mkdir(
* equal to length of the root path). The path may be less than the
* root path length on Windows, where `C:` == `C:/`.
*/
if
((
len
==
1
&&
parent_path
.
ptr
[
0
]
==
'.'
)
||
len
<=
root_len
)
{
if
((
len
==
1
&&
parent_path
.
ptr
[
0
]
==
'.'
)
||
(
len
==
1
&&
parent_path
.
ptr
[
0
]
==
'/'
)
||
len
<=
root_len
)
{
relative
=
make_path
.
ptr
;
break
;
}
...
...
tests/repo/init.c
View file @
f92d495d
...
...
@@ -878,14 +878,55 @@ void test_repo_init__at_filesystem_root(void)
git_repository_free
(
repo
);
}
void
test_repo_init__nonexist
ent_paths
(
void
)
void
test_repo_init__nonexist
ing_directory
(
void
)
{
git_repository_init_options
opts
=
GIT_REPOSITORY_INIT_OPTIONS_INIT
;
git_repository
*
repo
;
/*
* If creating a repo with non-existing parent directories, then libgit2
* will by default create the complete directory hierarchy if using
* `git_repository_init`. Thus, let's use the extended version and not
* set the `GIT_REPOSITORY_INIT_MKPATH` flag.
*/
cl_git_fail
(
git_repository_init_ext
(
&
repo
,
"nonexisting/path"
,
&
opts
));
}
void
test_repo_init__nonexisting_root
(
void
)
{
#ifdef GIT_WIN32
git_repository
*
repo
;
/*
* This really only depends on the nonexistence of the Q: drive. We
* cannot implement the equivalent test on Unix systems, as there is
* fundamentally no path that is disconnected from the root directory.
*/
cl_git_fail
(
git_repository_init
(
&
repo
,
"Q:/non/existent/path"
,
0
));
cl_git_fail
(
git_repository_init
(
&
repo
,
"Q:
\\
non
\\
existent
\\
path"
,
0
));
#else
cl_git_fail
(
git_repository_init
(
&
repo
,
"/non/existent/path"
,
0
));
clar__skip
();
#endif
}
void
test_repo_init__unwriteable_directory
(
void
)
{
#ifndef GIT_WIN32
git_repository
*
repo
;
if
(
geteuid
()
==
0
)
clar__skip
();
/*
* Create a non-writeable directory so that we cannot create directories
* inside of it. The root user has CAP_DAC_OVERRIDE, so he doesn't care
* for the directory permissions and thus we need to skip the test if
* run as root user.
*/
cl_must_pass
(
p_mkdir
(
"unwriteable"
,
0444
));
cl_git_fail
(
git_repository_init
(
&
repo
,
"unwriteable/repo"
,
0
));
cl_must_pass
(
p_rmdir
(
"unwriteable"
));
#else
clar__skip
();
#endif
}
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