builtin/clone: don't apply "core.sharedRepository" to leading dirs
When creating a repository via git-clone(1) we create leading directories with `safe_create_leading_directories()`. We have adapted git-init(1) in a preceding commit to instead use the variant of this function that doesn't honor "core.sharedRepository". In that subcommand it didn't have an effect though as we explicitly unset the value of that configuration anyway, so we never honored that config. In git-clone(1) it's a bit of a different thing though: while the repository isn't initialized at the point in time where we call the function, we didn't explicitly unset the value. Consequently we _do_ honor the configuration here, but when it's configured in global- or system-level scope. This divergence doesn't seem to be intentional -- I cannot think of any good reason why git-init(1) and git-clone(1) should have divergent behaviour here. Adapt git-clone(1) to work the same as git-init(1) by also using the `no_share()` variants to create leading directories. Add tests for both commands. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>seen
parent
8f17ac5de4
commit
8f74abc2de
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue