Skip to content

Commit de5737c

Browse files
bk2204gitster
authored andcommitted
t5308: make test work with SHA-256
This test needs multiple object IDs that have the same first byte. Update the pack test code to generate a suitable packed value for SHA-256. Update the test to use this value when using SHA-256. Signed-off-by: brian m. carlson <[email protected]> Reviewed-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e0a646e commit de5737c

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

t/lib-pack.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ pack_obj () {
9393
;;
9494
esac
9595
;;
96+
# blob containing "\3\326"
97+
471819e8c52bf11513f100b2810a8aa0622d5cd3d1c913758a071dd4b3bad8fe)
98+
case "$2" in
99+
'')
100+
printf '\062\170\234\143\276\006\000\000\336\000\332'
101+
return
102+
;;
103+
esac
96104
esac
97105

98106
# If it's not a delta, we can convince pack-objects to generate a pack

t/t5308-pack-detect-duplicates.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,27 @@ test_description='handling of duplicate objects in incoming packfiles'
44
. ./test-lib.sh
55
. "$TEST_DIRECTORY"/lib-pack.sh
66

7-
if ! test_have_prereq SHA1
8-
then
9-
skip_all='not using SHA-1 for objects'
10-
test_done
11-
fi
7+
test_expect_success 'setup' '
8+
test_oid_cache <<-EOF
9+
lo_oid sha1:e68fe8129b546b101aee9510c5328e7f21ca1d18
10+
lo_oid sha256:471819e8c52bf11513f100b2810a8aa0622d5cd3d1c913758a071dd4b3bad8fe
11+
12+
missing_oid sha1:e69d000000000000000000000000000000000000
13+
missing_oid sha256:4720000000000000000000000000000000000000000000000000000000000000
14+
EOF
15+
'
1216

1317
# The sha1s we have in our pack. It's important that these have the same
1418
# starting byte, so that they end up in the same fanout section of the index.
1519
# That lets us make sure we are exercising the binary search with both sets.
16-
LO_SHA1=e68fe8129b546b101aee9510c5328e7f21ca1d18
17-
HI_SHA1=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
20+
LO_SHA1=$(test_oid lo_oid)
21+
HI_SHA1=$EMPTY_BLOB
1822

1923
# And here's a "missing sha1" which will produce failed lookups. It must also
2024
# be in the same fanout section, and should be between the two (so that during
2125
# our binary search, we are sure to end up looking at one or the other of the
2226
# duplicate runs).
23-
MISSING_SHA1='e69d000000000000000000000000000000000000'
27+
MISSING_SHA1=$(test_oid missing_oid)
2428

2529
# git will never intentionally create packfiles with
2630
# duplicate objects, so we have to construct them by hand.

0 commit comments

Comments
 (0)