Merge branch 'ss/safe-create-leading-dir-with-slash'
"git clone $origin foo\bar\baz" on Windows failed to create the leading directories (i.e. a moral-equivalent of "mkdir -p"). * ss/safe-create-leading-dir-with-slash: safe_create_leading_directories(): on Windows, \ can separate path components
This commit is contained in:
commit
33d4669aaa
12
sha1_file.c
12
sha1_file.c
@ -112,17 +112,21 @@ enum scld_error safe_create_leading_directories(char *path)
|
|||||||
|
|
||||||
while (ret == SCLD_OK && next_component) {
|
while (ret == SCLD_OK && next_component) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char *slash = strchr(next_component, '/');
|
char *slash = next_component, slash_character;
|
||||||
|
|
||||||
if (!slash)
|
while (*slash && !is_dir_sep(*slash))
|
||||||
|
slash++;
|
||||||
|
|
||||||
|
if (!*slash)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
next_component = slash + 1;
|
next_component = slash + 1;
|
||||||
while (*next_component == '/')
|
while (is_dir_sep(*next_component))
|
||||||
next_component++;
|
next_component++;
|
||||||
if (!*next_component)
|
if (!*next_component)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
slash_character = *slash;
|
||||||
*slash = '\0';
|
*slash = '\0';
|
||||||
if (!stat(path, &st)) {
|
if (!stat(path, &st)) {
|
||||||
/* path exists */
|
/* path exists */
|
||||||
@ -148,7 +152,7 @@ enum scld_error safe_create_leading_directories(char *path)
|
|||||||
} else if (adjust_shared_perm(path)) {
|
} else if (adjust_shared_perm(path)) {
|
||||||
ret = SCLD_PERMS;
|
ret = SCLD_PERMS;
|
||||||
}
|
}
|
||||||
*slash = '/';
|
*slash = slash_character;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user