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 <sandals@crustytoothpaste.net> Reviewed-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Jul 29, 2020 at 23:14 UTC
de5737caf32bedca5e3c7b04a9dd5c12499b35e9
2 files changed
+20
-8
t/lib-pack.sh
+8
@@ -93,6 +93,14 @@ pack_obj () {
93
;;
94
esac
95
;;
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
104
esac
105
106
# If it's not a delta, we can convince pack-objects to generate a pack
t/t5308-pack-detect-duplicates.sh
+12
-8
@@ -4,23 +4,27 @@ test_description='handling of duplicate objects in incoming packfiles'
4
. ./test-lib.sh
5
. "$TEST_DIRECTORY"/lib-pack.sh
6
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
+'
16
17
# The sha1s we have in our pack. It's important that these have the same
18
# starting byte, so that they end up in the same fanout section of the index.
19
# 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
22
23
# And here's a "missing sha1" which will produce failed lookups. It must also
24
# be in the same fanout section, and should be between the two (so that during
25
# our binary search, we are sure to end up looking at one or the other of the
26
# duplicate runs).
23
-MISSING_SHA1='e69d000000000000000000000000000000000000'
27
+MISSING_SHA1=$(test_oid missing_oid)
28
29
# git will never intentionally create packfiles with
30
# duplicate objects, so we have to construct them by hand.