summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2020-08-11 18:04:11 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-08-11 18:04:11 -0700
commite0ad9574ddf5bb14d9ed6808112485ce0da99fea (patch)
tree633eb1867a929588ec5b3d8af351a93ba62aac5a /t
parentFifth batch (diff)
parentt: remove test_oid_init in tests (diff)
downloadtgif-e0ad9574ddf5bb14d9ed6808112485ce0da99fea.tar.xz
Merge branch 'bc/sha-256-part-3'
The final leg of SHA-256 transition. * bc/sha-256-part-3: (39 commits) t: remove test_oid_init in tests docs: add documentation for extensions.objectFormat ci: run tests with SHA-256 t: make SHA1 prerequisite depend on default hash t: allow testing different hash algorithms via environment t: add test_oid option to select hash algorithm repository: enable SHA-256 support by default setup: add support for reading extensions.objectformat bundle: add new version for use with SHA-256 builtin/verify-pack: implement an --object-format option http-fetch: set up git directory before parsing pack hashes t0410: mark test with SHA1 prerequisite t5308: make test work with SHA-256 t9700: make hash size independent t9500: ensure that algorithm info is preserved in config t9350: make hash size independent t9301: make hash size independent t9300: use $ZERO_OID instead of hard-coded object ID t9300: abstract away SHA-1-specific constants t8011: make hash size independent ...
Diffstat (limited to 't')
-rw-r--r--t/helper/test-bloom.c2
-rw-r--r--t/lib-pack.sh11
-rw-r--r--t/lib-submodule-update.sh1
-rwxr-xr-xt/t0000-basic.sh15
-rwxr-xr-xt/t0001-init.sh33
-rwxr-xr-xt/t0410-partial-clone.sh4
-rwxr-xr-xt/t1006-cat-file.sh2
-rwxr-xr-xt/t1050-large.sh1
-rwxr-xr-xt/t1091-sparse-checkout-builtin.sh4
-rwxr-xr-xt/t1410-reflog.sh1
-rwxr-xr-xt/t1450-fsck.sh1
-rwxr-xr-xt/t1500-rev-parse.sh1
-rwxr-xr-xt/t3305-notes-fanout.sh2
-rwxr-xr-xt/t3308-notes-merge.sh1
-rwxr-xr-xt/t3404-rebase-interactive.sh49
-rwxr-xr-xt/t3600-rm.sh1
-rwxr-xr-xt/t3800-mktag.sh1
-rwxr-xr-xt/t4002-diff-basic.sh2
-rwxr-xr-xt/t4027-diff-submodule.sh1
-rwxr-xr-xt/t4134-apply-submodule.sh1
-rwxr-xr-xt/t4200-rerere.sh1
-rwxr-xr-xt/t4211-line-log.sh1
-rwxr-xr-xt/t5300-pack-object.sh3
-rwxr-xr-xt/t5302-pack-index.sh1
-rwxr-xr-xt/t5308-pack-detect-duplicates.sh20
-rwxr-xr-xt/t5313-pack-bounds-checks.sh1
-rwxr-xr-xt/t5318-commit-graph.sh3
-rwxr-xr-xt/t5319-multi-pack-index.sh1
-rwxr-xr-xt/t5324-split-commit-graph.sh1
-rwxr-xr-xt/t5504-fetch-receive-strict.sh1
-rwxr-xr-xt/t5510-fetch.sh16
-rwxr-xr-xt/t5530-upload-pack-error.sh1
-rwxr-xr-xt/t5562-http-backend-content-length.sh1
-rwxr-xr-xt/t5607-clone-bundle.sh31
-rwxr-xr-xt/t5702-protocol-v2.sh3
-rwxr-xr-xt/t5703-upload-pack-ref-in-want.sh1
-rwxr-xr-xt/t6006-rev-list-format.sh1
-rwxr-xr-xt/t6100-rev-list-in-order.sh4
-rwxr-xr-xt/t6101-rev-parse-parents.sh2
-rwxr-xr-xt/t6301-for-each-ref-errors.sh2
-rwxr-xr-xt/t6500-gc.sh27
-rwxr-xr-xt/t6501-freshen-objects.sh14
-rwxr-xr-xt/t7003-filter-branch.sh3
-rwxr-xr-xt/t7063-status-untracked-cache.sh150
-rwxr-xr-xt/t7102-reset.sh93
-rwxr-xr-xt/t7201-co.sh6
-rwxr-xr-xt/t7400-submodule-basic.sh26
-rwxr-xr-xt/t7405-submodule-merge.sh4
-rwxr-xr-xt/t7506-status-submodule.sh12
-rwxr-xr-xt/t7508-status.sh2
-rwxr-xr-xt/t8002-blame.sh18
-rwxr-xr-xt/t8003-blame-corner-cases.sh3
-rwxr-xr-xt/t8011-blame-split-file.sh2
-rwxr-xr-xt/t9300-fast-import.sh118
-rwxr-xr-xt/t9301-fast-import-notes.sh12
-rwxr-xr-xt/t9350-fast-export.sh14
-rwxr-xr-xt/t9500-gitweb-standalone-no-errors.sh22
-rwxr-xr-xt/t9700/test.pl6
-rw-r--r--t/test-lib-functions.sh16
-rw-r--r--t/test-lib.sh9
60 files changed, 481 insertions, 305 deletions
diff --git a/t/helper/test-bloom.c b/t/helper/test-bloom.c
index f0aa80b98e..5e77d56f59 100644
--- a/t/helper/test-bloom.c
+++ b/t/helper/test-bloom.c
@@ -50,6 +50,8 @@ static const char *bloom_usage = "\n"
int cmd__bloom(int argc, const char **argv)
{
+ setup_git_directory();
+
if (argc < 2)
usage(bloom_usage);
diff --git a/t/lib-pack.sh b/t/lib-pack.sh
index f3463170b3..bb8938ccbe 100644
--- a/t/lib-pack.sh
+++ b/t/lib-pack.sh
@@ -35,8 +35,6 @@ pack_header () {
# have hardcoded some well-known objects. See the case statements below for the
# complete list.
pack_obj () {
- test_oid_init
-
case "$1" in
# empty blob
$EMPTY_BLOB)
@@ -93,6 +91,14 @@ pack_obj () {
;;
esac
;;
+ # blob containing "\3\326"
+ 471819e8c52bf11513f100b2810a8aa0622d5cd3d1c913758a071dd4b3bad8fe)
+ case "$2" in
+ '')
+ printf '\062\170\234\143\276\006\000\000\336\000\332'
+ return
+ ;;
+ esac
esac
# If it's not a delta, we can convince pack-objects to generate a pack
@@ -113,7 +119,6 @@ pack_obj () {
# Compute and append pack trailer to "$1"
pack_trailer () {
- test_oid_init &&
test-tool $(test_oid algo) -b <"$1" >trailer.tmp &&
cat trailer.tmp >>"$1" &&
rm -f trailer.tmp
diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh
index 07c822c8ff..87a759149f 100644
--- a/t/lib-submodule-update.sh
+++ b/t/lib-submodule-update.sh
@@ -196,7 +196,6 @@ test_git_directory_exists () {
# the submodule repo if it doesn't exist and configures the most problematic
# settings for diff.ignoreSubmodules.
prolog () {
- test_oid_init &&
(test -d submodule_update_repo || create_lib_submodule_repo) &&
test_config_global diff.ignoreSubmodules all &&
test_config diff.ignoreSubmodules all
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 90bf1dbc8d..923281af93 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -891,10 +891,6 @@ test_expect_success 'test_atexit is run' "
test_path_is_missing also-clean-atexit
"
-test_expect_success 'test_oid setup' '
- test_oid_init
-'
-
test_expect_success 'test_oid provides sane info by default' '
test_oid zero >actual &&
grep "^00*\$" actual &&
@@ -928,6 +924,17 @@ test_expect_success 'test_oid can look up data for SHA-256' '
test "$hexsz" -eq 64
'
+test_expect_success 'test_oid can look up data for a specified algorithm' '
+ rawsz="$(test_oid --hash=sha1 rawsz)" &&
+ hexsz="$(test_oid --hash=sha1 hexsz)" &&
+ test "$rawsz" -eq 20 &&
+ test "$hexsz" -eq 40 &&
+ rawsz="$(test_oid --hash=sha256 rawsz)" &&
+ hexsz="$(test_oid --hash=sha256 hexsz)" &&
+ test "$rawsz" -eq 32 &&
+ test "$hexsz" -eq 64
+'
+
test_expect_success 'test_bool_env' '
(
sane_unset envvar &&
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 6d2467995e..d71d4c7238 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -441,6 +441,39 @@ test_expect_success 're-init from a linked worktree' '
)
'
+test_expect_success 'init honors GIT_DEFAULT_HASH' '
+ GIT_DEFAULT_HASH=sha1 git init sha1 &&
+ git -C sha1 rev-parse --show-object-format >actual &&
+ echo sha1 >expected &&
+ test_cmp expected actual &&
+ GIT_DEFAULT_HASH=sha256 git init sha256 &&
+ git -C sha256 rev-parse --show-object-format >actual &&
+ echo sha256 >expected &&
+ test_cmp expected actual
+'
+
+test_expect_success 'init honors --object-format' '
+ git init --object-format=sha1 explicit-sha1 &&
+ git -C explicit-sha1 rev-parse --show-object-format >actual &&
+ echo sha1 >expected &&
+ test_cmp expected actual &&
+ git init --object-format=sha256 explicit-sha256 &&
+ git -C explicit-sha256 rev-parse --show-object-format >actual &&
+ echo sha256 >expected &&
+ test_cmp expected actual
+'
+
+test_expect_success 'extensions.objectFormat is not allowed with repo version 0' '
+ git init --object-format=sha256 explicit-v0 &&
+ git -C explicit-v0 config core.repositoryformatversion 0 &&
+ test_must_fail git -C explicit-v0 rev-parse --show-object-format
+'
+
+test_expect_success 'init rejects attempts to initialize with different hash' '
+ test_must_fail git -C sha1 init --object-format=sha256 &&
+ test_must_fail git -C sha256 init --object-format=sha1
+'
+
test_expect_success MINGW 'core.hidedotfiles = false' '
git config --global core.hidedotfiles false &&
rm -rf newdir &&
diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh
index 6aa0f313bd..a5ebdf9ff3 100755
--- a/t/t0410-partial-clone.sh
+++ b/t/t0410-partial-clone.sh
@@ -42,7 +42,7 @@ test_expect_success 'convert shallow clone to partial clone' '
test_cmp_config -C client 1 core.repositoryformatversion
'
-test_expect_success 'convert to partial clone with noop extension' '
+test_expect_success SHA1 'convert to partial clone with noop extension' '
rm -fr server client &&
test_create_repo server &&
test_commit -C server my_commit 1 &&
@@ -53,7 +53,7 @@ test_expect_success 'convert to partial clone with noop extension' '
git -C client fetch --unshallow --filter="blob:none"
'
-test_expect_success 'converting to partial clone fails with unrecognized extension' '
+test_expect_success SHA1 'converting to partial clone fails with unrecognized extension' '
rm -fr server client &&
test_create_repo server &&
test_commit -C server my_commit 1 &&
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
index 43c4be1e5e..2f501d2dc9 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -140,8 +140,6 @@ test_expect_success '--batch-check without %(rest) considers whole line' '
test_cmp expect actual
'
-test_oid_init
-
tree_sha1=$(git write-tree)
tree_size=$(($(test_oid rawsz) + 13))
tree_pretty_content="100644 blob $hello_sha1 hello"
diff --git a/t/t1050-large.sh b/t/t1050-large.sh
index 6a56d1ca24..61e89a8071 100755
--- a/t/t1050-large.sh
+++ b/t/t1050-large.sh
@@ -12,7 +12,6 @@ file_size () {
}
test_expect_success setup '
- test_oid_init &&
# clone does not allow us to pass core.bigfilethreshold to
# new repos, so set core.bigfilethreshold globally
git config --global core.bigfilethreshold 200k &&
diff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh
index 7cd45fc139..84acfc48b6 100755
--- a/t/t1091-sparse-checkout-builtin.sh
+++ b/t/t1091-sparse-checkout-builtin.sh
@@ -369,7 +369,7 @@ test_expect_success 'sparse-checkout (init|set|disable) warns with unmerged stat
git clone repo unmerged &&
cat >input <<-EOF &&
- 0 0000000000000000000000000000000000000000 folder1/a
+ 0 $ZERO_OID folder1/a
100644 $(git -C unmerged rev-parse HEAD:folder1/a) 1 folder1/a
EOF
git -C unmerged update-index --index-info <input &&
@@ -396,7 +396,7 @@ test_expect_success 'sparse-checkout reapply' '
echo dirty >tweak/deep/deeper2/a &&
cat >input <<-EOF &&
- 0 0000000000000000000000000000000000000000 folder1/a
+ 0 $ZERO_OID folder1/a
100644 $(git -C tweak rev-parse HEAD:folder1/a) 1 folder1/a
EOF
git -C tweak update-index --index-info <input &&
diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh
index 76d9b744a6..730a43d9dd 100755
--- a/t/t1410-reflog.sh
+++ b/t/t1410-reflog.sh
@@ -54,7 +54,6 @@ check_dont_have () {
}
test_expect_success setup '
- test_oid_init &&
mkdir -p A/B &&
echo rat >C &&
echo ox >A/D &&
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index af2a2c4682..b17f5c21fb 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -9,7 +9,6 @@ test_description='git fsck random collection of tests
. ./test-lib.sh
test_expect_success setup '
- test_oid_init &&
git config gc.auto 0 &&
git config i18n.commitencoding ISO-8859-1 &&
test_commit A fileA one &&
diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
index 603019b541..408b97d5af 100755
--- a/t/t1500-rev-parse.sh
+++ b/t/t1500-rev-parse.sh
@@ -59,7 +59,6 @@ test_rev_parse () {
ROOT=$(pwd)
test_expect_success 'setup' '
- test_oid_init &&
mkdir -p sub/dir work &&
cp -R .git repo.git
'
diff --git a/t/t3305-notes-fanout.sh b/t/t3305-notes-fanout.sh
index 3b4753e1b4..94c1b02251 100755
--- a/t/t3305-notes-fanout.sh
+++ b/t/t3305-notes-fanout.sh
@@ -7,7 +7,7 @@ test_description='Test that adding/removing many notes triggers automatic fanout
path_has_fanout() {
path=$1 &&
fanout=$2 &&
- after_last_slash=$((40 - $fanout * 2)) &&
+ after_last_slash=$(($(test_oid hexsz) - $fanout * 2)) &&
echo $path | grep -q "^\([0-9a-f]\{2\}/\)\{$fanout\}[0-9a-f]\{$after_last_slash\}$"
}
diff --git a/t/t3308-notes-merge.sh b/t/t3308-notes-merge.sh
index 790e292966..d69c84c640 100755
--- a/t/t3308-notes-merge.sh
+++ b/t/t3308-notes-merge.sh
@@ -22,7 +22,6 @@ test_expect_success setup '
# Copy notes to remote-notes
git fetch . refs/notes/*:refs/remote-notes/origin/* &&
- test_oid_init &&
test_oid_cache <<-EOF
hash4a sha1:5e93d24084d32e1cb61f7070505b9d2530cca987
hash3a sha1:8366731eeee53787d2bdf8fc1eff7d94757e8da0
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 4a7d21f898..9744e88760 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -1250,7 +1250,7 @@ test_expect_success 'rebase -i error on commits with \ in message' '
test_expect_code 1 grep " emp" error
'
-test_expect_success SHA1 'short SHA-1 setup' '
+test_expect_success 'short commit ID setup' '
test_when_finished "git checkout master" &&
git checkout --orphan collide &&
git rm -rf . &&
@@ -1262,23 +1262,54 @@ test_expect_success SHA1 'short SHA-1 setup' '
)
'
-test_expect_success SHA1 'short SHA-1 collide' '
+if test -n "$GIT_TEST_FIND_COLLIDER"
+then
+ author="$(unset test_tick; test_tick; git var GIT_AUTHOR_IDENT)"
+ committer="$(unset test_tick; test_tick; git var GIT_COMMITTER_IDENT)"
+ blob="$(git rev-parse collide2:collide)"
+ from="$(git rev-parse collide1^0)"
+ repl="commit refs/heads/collider-&\\n"
+ repl="${repl}author $author\\ncommitter $committer\\n"
+ repl="${repl}data <<EOF\\ncollide2 &\\nEOF\\n"
+ repl="${repl}from $from\\nM 100644 $blob collide\\n"
+ test_seq 1 32768 | sed "s|.*|$repl|" >script &&
+ git fast-import <script &&
+ git pack-refs &&
+ git for-each-ref >refs &&
+ grep "^$(test_oid t3404_collision)" <refs >matches &&
+ cat matches &&
+ test_line_count -gt 2 matches || {
+ echo "Could not find a collider" >&2
+ exit 1
+ }
+fi
+
+test_expect_success 'short commit ID collide' '
+ test_oid_cache <<-EOF &&
+ # collision-related constants
+ t3404_collision sha1:6bcd
+ t3404_collision sha256:0161
+ t3404_collider sha1:ac4f2ee
+ t3404_collider sha256:16697
+ EOF
test_when_finished "reset_rebase && git checkout master" &&
git checkout collide &&
- colliding_sha1=6bcda37 &&
- test $colliding_sha1 = "$(git rev-parse HEAD | cut -c 1-7)" &&
+ colliding_id=$(test_oid t3404_collision) &&
+ hexsz=$(test_oid hexsz) &&
+ test $colliding_id = "$(git rev-parse HEAD | cut -c 1-4)" &&
+ test_config core.abbrev 4 &&
(
unset test_tick &&
test_tick &&
set_fake_editor &&
- FAKE_COMMIT_MESSAGE="collide2 ac4f2ee" \
+ FAKE_COMMIT_MESSAGE="collide2 $(test_oid t3404_collider)" \
FAKE_LINES="reword 1 break 2" git rebase -i HEAD~2 &&
- test $colliding_sha1 = "$(git rev-parse HEAD | cut -c 1-7)" &&
- grep "^pick $colliding_sha1 " \
+ test $colliding_id = "$(git rev-parse HEAD | cut -c 1-4)" &&
+ grep "^pick $colliding_id " \
.git/rebase-merge/git-rebase-todo.tmp &&
- grep "^pick [0-9a-f]\{40\}" \
+ grep "^pick [0-9a-f]\{$hexsz\}" \
.git/rebase-merge/git-rebase-todo &&
- grep "^pick [0-9a-f]\{40\}" \
+ grep "^pick [0-9a-f]\{$hexsz\}" \
.git/rebase-merge/git-rebase-todo.backup &&
git rebase --continue
) &&
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index f2c0168941..efec8d13b6 100755
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
@@ -241,7 +241,6 @@ test_expect_success 'refresh index before checking if it is up-to-date' '
'
test_expect_success 'choking "git rm" should not let it die with cruft' '
- test_oid_init &&
git reset -q --hard &&
test_when_finished "rm -f .git/index.lock && git reset -q --hard" &&
i=0 &&
diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh
index 64dcc5ec28..d696aa4e52 100755
--- a/t/t3800-mktag.sh
+++ b/t/t3800-mktag.sh
@@ -23,7 +23,6 @@ check_verify_failure () {
# first create a commit, so we have a valid object/type
# for the tag.
test_expect_success 'setup' '
- test_oid_init &&
echo Hello >A &&
git update-index --add A &&
git commit -m "Initial commit" &&
diff --git a/t/t4002-diff-basic.sh b/t/t4002-diff-basic.sh
index cbcdd10464..6a9f010197 100755
--- a/t/t4002-diff-basic.sh
+++ b/t/t4002-diff-basic.sh
@@ -10,8 +10,6 @@ test_description='Test diff raw-output.
. "$TEST_DIRECTORY"/lib-read-tree-m-3way.sh
-test_oid_init
-
test_oid_cache <<\EOF
aa_1 sha1:ccba72ad3888a3520b39efcf780b9ee64167535d
aa_1 sha256:9febfbf18197819b2735c45291f138525d2476d59470f98239647544586ba403
diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh
index e29deaf4a5..d7145ccca4 100755
--- a/t/t4027-diff-submodule.sh
+++ b/t/t4027-diff-submodule.sh
@@ -6,7 +6,6 @@ test_description='difference in submodules'
. "$TEST_DIRECTORY"/diff-lib.sh
test_expect_success setup '
- test_oid_init &&
test_tick &&
test_create_repo sub &&
(
diff --git a/t/t4134-apply-submodule.sh b/t/t4134-apply-submodule.sh
index 99ed4cc546..d1c16ba33c 100755
--- a/t/t4134-apply-submodule.sh
+++ b/t/t4134-apply-submodule.sh
@@ -8,7 +8,6 @@ test_description='git apply submodule tests'
. ./test-lib.sh
test_expect_success setup '
- test_oid_init &&
cat > create-sm.patch <<EOF &&
diff --git a/dir/sm b/dir/sm
new file mode 160000
diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
index 831d424c47..d94d25e4f0 100755
--- a/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
@@ -25,7 +25,6 @@ test_description='git rerere
. ./test-lib.sh
test_expect_success 'setup' '
- test_oid_init &&
cat >a1 <<-\EOF &&
Some title
==========
diff --git a/t/t4211-line-log.sh b/t/t4211-line-log.sh
index e186c83250..2d1d7b5d19 100755
--- a/t/t4211-line-log.sh
+++ b/t/t4211-line-log.sh
@@ -4,7 +4,6 @@ test_description='test log -L'
. ./test-lib.sh
test_expect_success 'setup (import history)' '
- test_oid_init &&
git fast-import < "$TEST_DIRECTORY"/t4211/history.export &&
git reset --hard
'
diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh
index d553d0ca46..3d6a93343a 100755
--- a/t/t5300-pack-object.sh
+++ b/t/t5300-pack-object.sh
@@ -12,8 +12,7 @@ TRASH=$(pwd)
test_expect_success \
'setup' \
- 'test_oid_init &&
- rm -f .git/index* &&
+ 'rm -f .git/index* &&
perl -e "print \"a\" x 4096;" > a &&
perl -e "print \"b\" x 4096;" > b &&
perl -e "print \"c\" x 4096;" > c &&
diff --git a/t/t5302-pack-index.sh b/t/t5302-pack-index.sh
index 8981c9b90e..119494bd64 100755
--- a/t/t5302-pack-index.sh
+++ b/t/t5302-pack-index.sh
@@ -7,7 +7,6 @@ test_description='pack index with 64-bit offsets and object CRC'
. ./test-lib.sh
test_expect_success 'setup' '
- test_oid_init &&
rawsz=$(test_oid rawsz) &&
rm -rf .git &&
git init &&
diff --git a/t/t5308-pack-detect-duplicates.sh b/t/t5308-pack-detect-duplicates.sh
index 6845c1f3c3..693b2411c8 100755
--- a/t/t5308-pack-detect-duplicates.sh
+++ b/t/t5308-pack-detect-duplicates.sh
@@ -4,23 +4,27 @@ test_description='handling of duplicate objects in incoming packfiles'
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-pack.sh
-if ! test_have_prereq SHA1
-then
- skip_all='not using SHA-1 for objects'
- test_done
-fi
+test_expect_success 'setup' '
+ test_oid_cache <<-EOF
+ lo_oid sha1:e68fe8129b546b101aee9510c5328e7f21ca1d18
+ lo_oid sha256:471819e8c52bf11513f100b2810a8aa0622d5cd3d1c913758a071dd4b3bad8fe
+
+ missing_oid sha1:e69d000000000000000000000000000000000000
+ missing_oid sha256:4720000000000000000000000000000000000000000000000000000000000000
+ EOF
+'
# The sha1s we have in our pack. It's important that these have the same
# starting byte, so that they end up in the same fanout section of the index.
# That lets us make sure we are exercising the binary search with both sets.
-LO_SHA1=e68fe8129b546b101aee9510c5328e7f21ca1d18
-HI_SHA1=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
+LO_SHA1=$(test_oid lo_oid)
+HI_SHA1=$EMPTY_BLOB
# And here's a "missing sha1" which will produce failed lookups. It must also
# be in the same fanout section, and should be between the two (so that during
# our binary search, we are sure to end up looking at one or the other of the
# duplicate runs).
-MISSING_SHA1='e69d000000000000000000000000000000000000'
+MISSING_SHA1=$(test_oid missing_oid)
# git will never intentionally create packfiles with
# duplicate objects, so we have to construct them by hand.
diff --git a/t/t5313-pack-bounds-checks.sh b/t/t5313-pack-bounds-checks.sh
index 2a4557efc2..535313e4dc 100755
--- a/t/t5313-pack-bounds-checks.sh
+++ b/