summaryrefslogtreecommitdiff
path: root/src/fileops.c
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2010-12-20 10:43:23 +0100
committernulltoken <emeric.fermas@gmail.com>2010-12-20 10:43:23 +0100
commit412de9a637e94b877c7762d90c87525f35018083 (patch)
tree01cdda6ff82b94652e0e943294615fafa377bba2 /src/fileops.c
parent40c44d2fb63dbe484824c9dbc7c098c797ad10a1 (diff)
downloadlibgit2-412de9a637e94b877c7762d90c87525f35018083.tar.gz
Made gitfo_mkdir_recurs() gracefully recover when a given directory already exists.
Diffstat (limited to 'src/fileops.c')
-rw-r--r--src/fileops.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/fileops.c b/src/fileops.c
index a25796a7b..f2a08e8fb 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -323,10 +323,15 @@ int gitfo_mkdir_recurs(const char *path, int mode)
error = GIT_SUCCESS;
pp = path_copy;
- while (error == 0 && (sp = strchr(pp, '/')) != 0) {
+ while (error == GIT_SUCCESS && (sp = strchr(pp, '/')) != 0) {
if (sp != pp && gitfo_isdir(path_copy) < GIT_SUCCESS) {
*sp = 0;
error = gitfo_mkdir(path_copy, mode);
+
+ /* Do not choke while trying to recreate an existing directory */
+ if (errno == EEXIST)
+ error = GIT_SUCCESS;
+
*sp = '/';
}