summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 16967d3b9a..5f573d9b81 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -124,8 +124,13 @@ int safe_create_leading_directories(char *path)
}
}
else if (mkdir(path, 0777)) {
- *pos = '/';
- return -1;
+ if (errno == EEXIST &&
+ !stat(path, &st) && S_ISDIR(st.st_mode)) {
+ ; /* somebody created it since we checked */
+ } else {
+ *pos = '/';
+ return -1;
+ }
}
else if (adjust_shared_perm(path)) {
*pos = '/';