@@ -586,6 +586,18 @@ test_expect_success 'GIT_DEFAULT_HASH overrides init.defaultObjectFormat' '
586586 echo sha256 >expected
587587'
588588
589+ for hash in sha1 sha256
590+ do
591+ test_expect_success " reinit repository with GIT_DEFAULT_HASH=$hash does not change format" '
592+ test_when_finished "rm -rf repo" &&
593+ git init repo &&
594+ git -C repo rev-parse --show-object-format >expect &&
595+ GIT_DEFAULT_HASH=$hash git init repo &&
596+ git -C repo rev-parse --show-object-format >actual &&
597+ test_cmp expect actual
598+ '
599+ done
600+
589601test_expect_success ' extensions.objectFormat is not allowed with repo version 0' '
590602 test_when_finished "rm -rf explicit-v0" &&
591603 git init --object-format=sha256 explicit-v0 &&
697709 git -C refformat rev-parse --show-ref-format >actual &&
698710 test_cmp expect actual
699711 '
712+
713+ test_expect_success " reinit repository with GIT_DEFAULT_REF_FORMAT=$format does not change format" '
714+ test_when_finished "rm -rf refformat" &&
715+ git init refformat &&
716+ git -C refformat rev-parse --show-ref-format >expect &&
717+ GIT_DEFAULT_REF_FORMAT=$format git init refformat &&
718+ git -C refformat rev-parse --show-ref-format >actual &&
719+ test_cmp expect actual
720+ '
700721done
701722
702723test_expect_success " --ref-format= overrides GIT_DEFAULT_REF_FORMAT" '
@@ -861,15 +882,6 @@ test_expect_success 're-init with includeIf.onbranch condition' '
861882 test_cmp expect actual
862883'
863884
864- test_expect_success ' re-init with includeIf.onbranch condition' '
865- test_when_finished "rm -rf repo" &&
866- git init repo &&
867- git -c includeIf.onbranch:nonexistent.path=/does/not/exist init repo &&
868- echo $GIT_DEFAULT_REF_FORMAT >expect &&
869- git -C repo rev-parse --show-ref-format >actual &&
870- test_cmp expect actual
871- '
872-
873885test_expect_success ' re-init skips non-matching includeIf.onbranch' '
874886 test_when_finished "rm -rf repo config" &&
875887 cat >config <<-EOF &&
0 commit comments