diff options
author | Romain Geissler <romain.geissler@gmail.com> | 2011-06-05 00:20:35 +0200 |
---|---|---|
committer | Romain Geissler <romain.geissler@gmail.com> | 2011-06-05 00:20:35 +0200 |
commit | a993e4fe0612b2f08885fff283175fd1238a1be6 (patch) | |
tree | a81039c372c86dd032980656c3e74d8002998067 | |
parent | f2a60854cd174006fc2fa9b9f2af4c3e54672e96 (diff) | |
download | libgit2-a993e4fe0612b2f08885fff283175fd1238a1be6.tar.gz |
Fileops: Fixed gitfo_mkdir_recurs so that it proprely works with a path without trailing slash.
It used to discard the last directory if the path didn't have a trailing slash.
-rw-r--r-- | src/fileops.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/fileops.c b/src/fileops.c index 56bf2927f..b1a6bb8b1 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -380,7 +380,7 @@ int gitfo_mkdir_recurs(const char *path, int mode) if (root_path_offset > 0) pp += root_path_offset; /* On Windows, will skip the drive name (eg. C: or D:) */ - while (error == GIT_SUCCESS && (sp = strchr(pp, '/')) != 0) { + while (error == GIT_SUCCESS && (sp = strchr(pp, '/')) != NULL) { if (sp != pp && gitfo_isdir(path_copy) < GIT_SUCCESS) { *sp = 0; error = gitfo_mkdir(path_copy, mode); @@ -395,8 +395,11 @@ int gitfo_mkdir_recurs(const char *path, int mode) pp = sp + 1; } - if (*(pp - 1) != '/' && error == GIT_SUCCESS) + if (*pp != '\0' && error == GIT_SUCCESS) { error = gitfo_mkdir(path, mode); + if (errno == EEXIST) + error = GIT_SUCCESS; + } free(path_copy); |