Skip to content

Commit

Permalink
Merge branch 'sw/safe-create-leading-dir-race'
Browse files Browse the repository at this point in the history
* sw/safe-create-leading-dir-race:
  safe_create_leading_directories: fix race that could give a false negative
  • Loading branch information
Junio C Hamano committed Apr 2, 2013
2 parents c5f05b2 + 928734d commit 37ba4c6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '/';
Expand Down

0 comments on commit 37ba4c6

Please sign in to comment.