Skip to content

Commit

Permalink
t5308: make test work with SHA-256
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bk2204 authored and gitster committed Jul 30, 2020
1 parent e0a646e commit de5737c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
8 changes: 8 additions & 0 deletions t/lib-pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,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
Expand Down
20 changes: 12 additions & 8 deletions t/t5308-pack-detect-duplicates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit de5737c

Please sign in to comment.