mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-21 14:39:10 +00:00
mkdir
: cope with root path on win32
This commit is contained in:
parent
e164ddb11d
commit
9ce2e7b317
@ -408,7 +408,7 @@ int git_futils_mkdir(
|
|||||||
struct git_futils_mkdir_options opts = { 0 };
|
struct git_futils_mkdir_options opts = { 0 };
|
||||||
struct stat st;
|
struct stat st;
|
||||||
size_t depth = 0;
|
size_t depth = 0;
|
||||||
int len = 0, error;
|
int len = 0, root_len, error;
|
||||||
|
|
||||||
if ((error = git_buf_puts(&make_path, path)) < 0 ||
|
if ((error = git_buf_puts(&make_path, path)) < 0 ||
|
||||||
(error = mkdir_canonicalize(&make_path, flags)) < 0 ||
|
(error = mkdir_canonicalize(&make_path, flags)) < 0 ||
|
||||||
@ -416,6 +416,8 @@ int git_futils_mkdir(
|
|||||||
make_path.size == 0)
|
make_path.size == 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
|
root_len = git_path_root(make_path.ptr);
|
||||||
|
|
||||||
/* find the first parent directory that exists. this will be used
|
/* find the first parent directory that exists. this will be used
|
||||||
* as the base to dirname_relative.
|
* 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
|
/* 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.
|
* or rooted. either way, give up and make the entire path.
|
||||||
*/
|
*/
|
||||||
if (len == 1 &&
|
if ((len == 1 && parent_path.ptr[0] == '.') || len == root_len+1) {
|
||||||
(parent_path.ptr[0] == '.' || parent_path.ptr[0] == '/')) {
|
|
||||||
relative = make_path.ptr;
|
relative = make_path.ptr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ extern const char *git_path_topdir(const char *path);
|
|||||||
* This will return a number >= 0 which is the offset to the start of the
|
* This will return a number >= 0 which is the offset to the start of the
|
||||||
* path, if the path is rooted (i.e. "/rooted/path" returns 0 and
|
* path, if the path is rooted (i.e. "/rooted/path" returns 0 and
|
||||||
* "c:/windows/rooted/path" returns 2). If the path is not rooted, this
|
* "c:/windows/rooted/path" returns 2). If the path is not rooted, this
|
||||||
* returns < 0.
|
* returns -1.
|
||||||
*/
|
*/
|
||||||
extern int git_path_root(const char *path);
|
extern int git_path_root(const char *path);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user