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 /sha1_file.c | |
parent | c5f05b23562be8c0e4ddfe9ca89720f611836a28 (diff) | |
parent | 928734d99370e2478e3b3881e5b0aa79745ac27c (diff) | |
download | git-37ba4c61d04d0782bd34971be5cc4eec10f59d36.tar.gz |
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
Diffstat (limited to 'sha1_file.c')
-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 = '/'; |