aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-02-10 10:18:29 -0800
committerJunio C Hamano <gitster@pobox.com>2025-02-10 10:18:29 -0800
commit442b7e0018fac61874a8423270e8fee2c0c7e689 (patch)
treebd6747143f56f6cb8db35c5bc91d3a1b8558e77c /t
parent9520f7d9985d8879bddd157309928fc0679c8e92 (diff)
parent7e88640cd1801b6fe0288f744da7310b4749c0c8 (diff)
downloadgit-442b7e0018fac61874a8423270e8fee2c0c7e689.tar.gz
Merge branch 'ps/setup-reinit-fixes'
"git init" to reinitialize a repository that already exists cannot change the hash function and ref backends; such a request is silently ignored now. * ps/setup-reinit-fixes: setup: fix reinit of repos with incompatible GIT_DEFAULT_HASH setup: fix reinit of repos with incompatible GIT_DEFAULT_REF_FORMAT t0001: remove duplicate test
Diffstat (limited to 't')
-rwxr-xr-xt/t0001-init.sh30
1 files changed, 21 insertions, 9 deletions
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 72a0c2e7d4..c49d9e0d38 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -586,6 +586,18 @@ test_expect_success 'GIT_DEFAULT_HASH overrides init.defaultObjectFormat' '
echo sha256 >expected
'
+for hash in sha1 sha256
+do
+ test_expect_success "reinit repository with GIT_DEFAULT_HASH=$hash does not change format" '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ git -C repo rev-parse --show-object-format >expect &&
+ GIT_DEFAULT_HASH=$hash git init repo &&
+ git -C repo rev-parse --show-object-format >actual &&
+ test_cmp expect actual
+ '
+done
+
test_expect_success 'extensions.objectFormat is not allowed with repo version 0' '
test_when_finished "rm -rf explicit-v0" &&
git init --object-format=sha256 explicit-v0 &&
@@ -697,6 +709,15 @@ do
git -C refformat rev-parse --show-ref-format >actual &&
test_cmp expect actual
'
+
+ test_expect_success "reinit repository with GIT_DEFAULT_REF_FORMAT=$format does not change format" '
+ test_when_finished "rm -rf refformat" &&
+ git init refformat &&
+ git -C refformat rev-parse --show-ref-format >expect &&
+ GIT_DEFAULT_REF_FORMAT=$format git init refformat &&
+ git -C refformat rev-parse --show-ref-format >actual &&
+ test_cmp expect actual
+ '
done
test_expect_success "--ref-format= overrides GIT_DEFAULT_REF_FORMAT" '
@@ -861,15 +882,6 @@ test_expect_success 're-init with includeIf.onbranch condition' '
test_cmp expect actual
'
-test_expect_success 're-init with includeIf.onbranch condition' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- git -c includeIf.onbranch:nonexistent.path=/does/not/exist init repo &&
- echo $GIT_DEFAULT_REF_FORMAT >expect &&
- git -C repo rev-parse --show-ref-format >actual &&
- test_cmp expect actual
-'
-
test_expect_success 're-init skips non-matching includeIf.onbranch' '
test_when_finished "rm -rf repo config" &&
cat >config <<-EOF &&