diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-04-02 15:09:48 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-04-02 15:09:48 -0700 |
commit | 37ba4c61d04d0782bd34971be5cc4eec10f59d36 (patch) | |
tree | 1a8e81ea59a5015e9aa532eaaae39520fbe4ebe2 | |
parent | Merge branch 'bk/document-commit-tree-S' (diff) | |
parent | safe_create_leading_directories: fix race that could give a false negative (diff) | |
download | tgif-37ba4c61d04d0782bd34971be5cc4eec10f59d36.tar.xz |
Merge branch 'sw/safe-create-leading-dir-race'
* sw/safe-create-leading-dir-race:
safe_create_leading_directories: fix race that could give a false negative
-rw-r--r-- | sha1_file.c | 9 |
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 = '/'; |