diff --git a/builtin/clone.c b/builtin/clone.c index b14264c33a..e72f8aa325 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -1133,7 +1133,7 @@ int cmd_clone(int argc, sigchain_push_common(remove_junk_on_signal); if (!option_bare) { - if (safe_create_leading_directories_const(the_repository, work_tree) < 0) + if (safe_create_leading_directories_no_share_const(work_tree) < 0) die_errno(_("could not create leading directories of '%s'"), work_tree); if (dest_exists) @@ -1153,7 +1153,7 @@ int cmd_clone(int argc, junk_git_dir_flags |= REMOVE_DIR_KEEP_TOPLEVEL; junk_git_dir = git_dir; } - if (safe_create_leading_directories_const(the_repository, git_dir) < 0) + if (safe_create_leading_directories_no_share_const(git_dir) < 0) die(_("could not create leading directories of '%s'"), git_dir); if (0 <= option_verbosity) { diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh index 0e0d07a1a1..3bc4bdb038 100755 --- a/t/t1301-shared-repo.sh +++ b/t/t1301-shared-repo.sh @@ -210,4 +210,46 @@ test_expect_success POSIXPERM 'template can set core.sharedrepository' ' test_cmp expect actual ' +test_expect_success POSIXPERM 'init does not apply core.sharedRepository to leading directories' ' + test_config_global core.sharedRepository 0666 && + umask 0077 && + test_when_finished "rm -rf dst" && + git init --bare dst/with/leading/dirs && + cat >expect <<-\EOF && + drwx------ + drwx------ + drwx------ + drwxrwxrwx + EOF + { + test_modebits dst && + test_modebits dst/with && + test_modebits dst/with/leading && + test_modebits dst/with/leading/dirs + } >actual && + test_cmp expect actual +' + +test_expect_success POSIXPERM 'clone does not apply core.sharedRepository to leading directories' ' + test_config_global core.sharedRepository 0666 && + umask 0077 && + test_when_finished "rm -rf source dst" && + git init source && + test_commit -C source initial && + git clone --bare source dst/with/leading/dirs && + cat >expect <<-\EOF && + drwx------ + drwx------ + drwx------ + drwxrwxrwx + EOF + { + test_modebits dst && + test_modebits dst/with && + test_modebits dst/with/leading && + test_modebits dst/with/leading/dirs + } >actual && + test_cmp expect actual +' + test_done