1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-19 22:16:21 +02:00

t1710: make hash independent

This test uses several index hashes, which necessarily depend on the
version of the index and the hash algorithm in use.  Use test_oid_cache
to provide values for these for both SHA-1 and SHA-256.  Also, compute
an object ID and use $EMPTY_BLOB to make the remainder of the tests
independent of the hash algorithm in use.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
brian m. carlson 2019-06-28 22:59:27 +00:00 committed by Junio C Hamano
parent 2e306f6c4f
commit bfefd5202b

View File

@ -20,6 +20,22 @@ create_non_racy_file () {
test-tool chmtime =-5 "$1"
}
test_expect_success 'setup' '
test_oid_cache <<-EOF
own_v3 sha1:8299b0bcd1ac364e5f1d7768efb62fa2da79a339
own_v3 sha256:38a6d2925e3eceec33ad7b34cbff4e0086caa0daf28f31e51f5bd94b4a7af86b
base_v3 sha1:39d890139ee5356c7ef572216cebcd27aa41f9df
base_v3 sha256:c9baeadf905112bf6c17aefbd7d02267afd70ded613c30cafed2d40cb506e1ed
own_v4 sha1:432ef4b63f32193984f339431fd50ca796493569
own_v4 sha256:6738ac6319c25b694afa7bcc313deb182d1a59b68bf7a47b4296de83478c0420
base_v4 sha1:508851a7f0dfa8691e9f69c7f055865389012491
base_v4 sha256:3177d4adfdd4b6904f7e921d91d715a471c0dde7cf6a4bba574927f02b699508
EOF
'
test_expect_success 'enable split index' '
git config splitIndex.maxPercentChange 100 &&
git update-index --split-index &&
@ -29,11 +45,11 @@ test_expect_success 'enable split index' '
# NEEDSWORK: Stop hard-coding checksums.
if test "$indexversion" = "4"
then
own=432ef4b63f32193984f339431fd50ca796493569
base=508851a7f0dfa8691e9f69c7f055865389012491
own=$(test_oid own_v4)
base=$(test_oid base_v4)
else
own=8299b0bcd1ac364e5f1d7768efb62fa2da79a339
base=39d890139ee5356c7ef572216cebcd27aa41f9df
own=$(test_oid own_v3)
base=$(test_oid base_v3)
fi &&
cat >expect <<-EOF &&
@ -99,17 +115,18 @@ test_expect_success 'enable split index again, "one" now belongs to base index"'
test_expect_success 'modify original file, base index untouched' '
echo modified | create_non_racy_file one &&
file1_blob=$(git hash-object one) &&
git update-index one &&
git ls-files --stage >ls-files.actual &&
cat >ls-files.expect <<-EOF &&
100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0 one
100644 $file1_blob 0 one
EOF
test_cmp ls-files.expect ls-files.actual &&
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
q_to_tab >expect <<-EOF &&
$BASE
100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
100644 $file1_blob 0Q
replacements: 0
deletions:
EOF
@ -121,7 +138,7 @@ test_expect_success 'add another file, which stays index' '
git update-index --add two &&
git ls-files --stage >ls-files.actual &&
cat >ls-files.expect <<-EOF &&
100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0 one
100644 $file1_blob 0 one
100644 $EMPTY_BLOB 0 two
EOF
test_cmp ls-files.expect ls-files.actual &&
@ -129,7 +146,7 @@ test_expect_success 'add another file, which stays index' '
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
q_to_tab >expect <<-EOF &&
$BASE
100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
100644 $file1_blob 0Q
100644 $EMPTY_BLOB 0 two
replacements: 0
deletions:
@ -141,14 +158,14 @@ test_expect_success 'remove file not in base index' '
git update-index --force-remove two &&
git ls-files --stage >ls-files.actual &&
cat >ls-files.expect <<-EOF &&
100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0 one
100644 $file1_blob 0 one
EOF
test_cmp ls-files.expect ls-files.actual &&
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
q_to_tab >expect <<-EOF &&
$BASE
100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
100644 $file1_blob 0Q
replacements: 0
deletions:
EOF
@ -237,9 +254,9 @@ test_expect_success 'set core.splitIndex config variable to true' '
git update-index --add three &&
git ls-files --stage >ls-files.actual &&
cat >ls-files.expect <<-EOF &&
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 three
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two
100644 $EMPTY_BLOB 0 one
100644 $EMPTY_BLOB 0 three
100644 $EMPTY_BLOB 0 two
EOF
test_cmp ls-files.expect ls-files.actual &&
BASE=$(test-tool dump-split-index .git/index | grep "^base") &&
@ -257,8 +274,8 @@ test_expect_success 'set core.splitIndex config variable to false' '
git update-index --force-remove three &&
git ls-files --stage >ls-files.actual &&
cat >ls-files.expect <<-EOF &&
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two
100644 $EMPTY_BLOB 0 one
100644 $EMPTY_BLOB 0 two
EOF
test_cmp ls-files.expect ls-files.actual &&
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
@ -285,7 +302,7 @@ test_expect_success 'set core.splitIndex config variable back to true' '
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
cat >expect <<-EOF &&
$BASE
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 four
100644 $EMPTY_BLOB 0 four
replacements:
deletions:
EOF
@ -309,7 +326,7 @@ test_expect_success 'check behavior with splitIndex.maxPercentChange unset' '
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
cat >expect <<-EOF &&
$BASE
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 six
100644 $EMPTY_BLOB 0 six
replacements:
deletions:
EOF