repo_set_hash_algo(the_repository, repo_fmt.hash_algo);
repo_set_ref_storage_format(the_repository, repo_fmt.ref_storage_format);
- prev_bare_repository = is_bare_repository();
-
+ /*
+ * Ensure `core.hidedotfiles` is processed. This must happen after we
+ * have set up the repository format such that we can evaluate
+ * includeIf conditions correctly in the case of re-initialization.
+ */
+ git_config(platform_core_config, NULL);
+
+ safe_create_dir(git_dir, 0);
+
- &repo_fmt, prev_bare_repository,
- init_shared_repository);
+ reinit = create_default_files(template_dir, original_git_dir,
++ &repo_fmt, init_shared_repository);
+
if (!(flags & INIT_DB_SKIP_REFDB))
create_reference_database(repo_fmt.ref_storage_format,
initial_branch, flags & INIT_DB_QUIET);
test_cmp expect actual
'
- test_expect_success 're-init with same format' '
- test_when_finished "rm -rf refformat" &&
- git init --ref-format=files refformat &&
- git init --ref-format=files refformat &&
- echo files >expect &&
- git -C refformat rev-parse --show-ref-format >actual &&
- test_cmp expect actual
- '
-backends="files"
++backends="files reftable"
+ for from_format in $backends
+ do
+ test_expect_success "re-init with same format ($from_format)" '
+ test_when_finished "rm -rf refformat" &&
+ git init --ref-format=$from_format refformat &&
+ git init --ref-format=$from_format refformat &&
+ echo $from_format >expect &&
+ git -C refformat rev-parse --show-ref-format >actual &&
+ test_cmp expect actual
+ '
+
+ for to_format in $backends
+ do
+ if test "$from_format" = "$to_format"
+ then
+ continue
+ fi
+
+ test_expect_success "re-init with different format fails ($from_format -> $to_format)" '
+ test_when_finished "rm -rf refformat" &&
+ git init --ref-format=$from_format refformat &&
+ cat >expect <<-EOF &&
+ fatal: attempt to reinitialize repository with different reference storage format
+ EOF
+ test_must_fail git init --ref-format=$to_format refformat 2>err &&
+ test_cmp expect err &&
+ echo $from_format >expect &&
+ git -C refformat rev-parse --show-ref-format >actual &&
+ test_cmp expect actual
+ '
+ done
+ done
test_expect_success 'init with --ref-format=garbage' '
test_when_finished "rm -rf refformat" &&