File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -489,10 +489,13 @@ int git_futils_mkdir(
489489
490490 assert (len );
491491
492- /* we've walked all the given path's parents and it's either relative
493- * or rooted. either way, give up and make the entire path.
492+ /*
493+ * We've walked all the given path's parents and it's either relative
494+ * (the parent is simply '.') or rooted (the length is less than or
495+ * equal to length of the root path). The path may be less than the
496+ * root path length on Windows, where `C:` == `C:/`.
494497 */
495- if ((len == 1 && parent_path .ptr [0 ] == '.' ) || len == root_len + 1 ) {
498+ if ((len == 1 && parent_path .ptr [0 ] == '.' ) || len <= root_len ) {
496499 relative = make_path .ptr ;
497500 break ;
498501 }
Original file line number Diff line number Diff line change @@ -877,3 +877,15 @@ void test_repo_init__at_filesystem_root(void)
877877 git_buf_dispose (& root );
878878 git_repository_free (repo );
879879}
880+
881+ void test_repo_init__nonexistent_paths (void )
882+ {
883+ git_repository * repo ;
884+
885+ #ifdef GIT_WIN32
886+ cl_git_fail (git_repository_init (& repo , "Q:/non/existent/path" , 0 ));
887+ cl_git_fail (git_repository_init (& repo , "Q:\\non\\existent\\path" , 0 ));
888+ #else
889+ cl_git_fail (git_repository_init (& repo , "/non/existent/path" , 0 ));
890+ #endif
891+ }
You can’t perform that action at this time.
0 commit comments