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
8311db0c
Commit
8311db0c
authored
Mar 19, 2015
by
Edward Thomson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3000 from libgit2/vmg/mkdir-ext
mkdir-ext: Assume directories don't exist; fix all race cases
parents
2c4e90f3
d88e6e9b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
src/fileops.c
+14
-5
No files found.
src/fileops.c
View file @
8311db0c
...
...
@@ -399,6 +399,7 @@ int git_futils_mkdir_ext(
/* walk down tail of path making each directory */
for
(
tail
=
&
make_path
.
ptr
[
root
];
*
tail
;
*
tail
=
lastch
)
{
bool
mkdir_attempted
=
false
;
/* advance tail to include next path component */
while
(
*
tail
==
'/'
)
...
...
@@ -417,16 +418,24 @@ int git_futils_mkdir_ext(
/* See what's going on with this path component */
opts
->
perfdata
.
stat_calls
++
;
retry_lstat
:
if
(
p_lstat
(
make_path
.
ptr
,
&
st
)
<
0
)
{
opts
->
perfdata
.
mkdir_calls
++
;
if
(
errno
!=
ENOENT
||
p_mkdir
(
make_path
.
ptr
,
mode
)
<
0
)
{
giterr_set
(
GITERR_OS
,
"Failed to make directory '%s'"
,
make_path
.
ptr
);
error
=
GIT_EEXISTS
;
if
(
mkdir_attempted
||
errno
!=
ENOENT
)
{
giterr_set
(
GITERR_OS
,
"Cannot access component in path '%s'"
,
make_path
.
ptr
);
error
=
-
1
;
goto
done
;
}
giterr_clear
();
opts
->
perfdata
.
mkdir_calls
++
;
mkdir_attempted
=
true
;
if
(
p_mkdir
(
make_path
.
ptr
,
mode
)
<
0
)
{
if
(
errno
==
EEXIST
)
goto
retry_lstat
;
giterr_set
(
GITERR_OS
,
"Failed to make directory '%s'"
,
make_path
.
ptr
);
error
=
-
1
;
goto
done
;
}
}
else
{
/* with exclusive create, existing dir is an error */
if
((
flags
&
GIT_MKDIR_EXCL
)
!=
0
)
{
...
...
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