summaryrefslogtreecommitdiff
path: root/src/fileops.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-09-17 12:48:37 -0400
committerEdward Thomson <ethomson@microsoft.com>2015-09-17 12:48:37 -0400
commit9ce2e7b317277b1a27bbcef77fab4d053019b8d8 (patch)
tree2ddb3b7fdad0097d7345221fc9afb2c53807e132 /src/fileops.c
parente164ddb11df0d7cd8178c759e323d18a7a7ea526 (diff)
downloadlibgit2-9ce2e7b317277b1a27bbcef77fab4d053019b8d8.tar.gz
`mkdir`: cope with root path on win32
Diffstat (limited to 'src/fileops.c')
-rw-r--r--src/fileops.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/fileops.c b/src/fileops.c
index 739a98fc4..57d2ce9c3 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -408,7 +408,7 @@ int git_futils_mkdir(
struct git_futils_mkdir_options opts = { 0 };
struct stat st;
size_t depth = 0;
- int len = 0, error;
+ int len = 0, root_len, error;
if ((error = git_buf_puts(&make_path, path)) < 0 ||
(error = mkdir_canonicalize(&make_path, flags)) < 0 ||
@@ -416,6 +416,8 @@ int git_futils_mkdir(
make_path.size == 0)
goto done;
+ root_len = git_path_root(make_path.ptr);
+
/* find the first parent directory that exists. this will be used
* as the base to dirname_relative.
*/
@@ -442,8 +444,7 @@ int git_futils_mkdir(
/* we've walked all the given path's parents and it's either relative
* or rooted. either way, give up and make the entire path.
*/
- if (len == 1 &&
- (parent_path.ptr[0] == '.' || parent_path.ptr[0] == '/')) {
+ if ((len == 1 && parent_path.ptr[0] == '.') || len == root_len+1) {
relative = make_path.ptr;
break;
}