Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
Merge branch 'sw/safe-create-leading-dir-race'
author
Junio C Hamano
<gitster@pobox.com>
Tue, 2 Apr 2013 22:09:48 +0000
(15:09 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Tue, 2 Apr 2013 22:09:48 +0000
(15:09 -0700)
* sw/safe-create-leading-dir-race:
safe_create_leading_directories: fix race that could give a false negative
sha1_file.c
patch
|
blob
|
history
raw
(from parent 1:
c5f05b2
)
diff --git
a/sha1_file.c
b/sha1_file.c
index 16967d3b9a86dc481a5161f0a98220e05790ca01..5f573d9b8107720b1a4f5c1da63a2d8e5b4369cf 100644
(file)
--- 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 = '/';