builtin/help.c: split "-a" processing into two
[gitweb.git] / sha1_file.c
index 16967d3b9a86dc481a5161f0a98220e05790ca01..5f573d9b8107720b1a4f5c1da63a2d8e5b4369cf 100644 (file)
@@ -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 = '/';