summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-01-27 18:45:37 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-01-27 18:45:37 (GMT)
commit33d4669aaa658f3e35f88748ed2db51c84203f62 (patch)
tree7dd0ad09f257e5eb8ef5b109a48c70bfc7f817fc /sha1_file.c
parentd0956cfa8ef8b3668ea6adc94b27f5dcdc93bde0 (diff)
parent0f5274033ecb0262dc77e4ed48fdb1ab07181bd8 (diff)
downloadgit-33d4669aaa658f3e35f88748ed2db51c84203f62.zip
git-33d4669aaa658f3e35f88748ed2db51c84203f62.tar.gz
git-33d4669aaa658f3e35f88748ed2db51c84203f62.tar.bz2
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
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 8b0849f..6e8c05d 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -112,17 +112,21 @@ enum scld_error safe_create_leading_directories(char *path)
while (ret == SCLD_OK && next_component) {
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;
next_component = slash + 1;
- while (*next_component == '/')
+ while (is_dir_sep(*next_component))
next_component++;
if (!*next_component)
break;
+ slash_character = *slash;
*slash = '\0';
if (!stat(path, &st)) {
/* path exists */
@@ -148,7 +152,7 @@ enum scld_error safe_create_leading_directories(char *path)
} else if (adjust_shared_perm(path)) {
ret = SCLD_PERMS;
}
- *slash = '/';
+ *slash = slash_character;
}
return ret;
}