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>

brian m. carlson committed Jun 28, 2019 at 22:59 UTC bfefd5202babaa1ace6b122e9df4959e3ec21e5d
1 file changed +34 -17
t/t1700-split-index.sh
+34 -17
@@ -20,6 +20,22 @@ create_non_racy_file () {
20 test-tool chmtime =-5 "$1"
21 }
22
23 +test_expect_success 'setup' '
24 + test_oid_cache <<-EOF
25 + own_v3 sha1:8299b0bcd1ac364e5f1d7768efb62fa2da79a339
26 + own_v3 sha256:38a6d2925e3eceec33ad7b34cbff4e0086caa0daf28f31e51f5bd94b4a7af86b
27 +
28 + base_v3 sha1:39d890139ee5356c7ef572216cebcd27aa41f9df
29 + base_v3 sha256:c9baeadf905112bf6c17aefbd7d02267afd70ded613c30cafed2d40cb506e1ed
30 +
31 + own_v4 sha1:432ef4b63f32193984f339431fd50ca796493569
32 + own_v4 sha256:6738ac6319c25b694afa7bcc313deb182d1a59b68bf7a47b4296de83478c0420
33 +
34 + base_v4 sha1:508851a7f0dfa8691e9f69c7f055865389012491
35 + base_v4 sha256:3177d4adfdd4b6904f7e921d91d715a471c0dde7cf6a4bba574927f02b699508
36 + EOF
37 +'
38 +
39 test_expect_success 'enable split index' '
40 git config splitIndex.maxPercentChange 100 &&
41 git update-index --split-index &&
@@ -29,11 +45,11 @@ test_expect_success 'enable split index' '
45 # NEEDSWORK: Stop hard-coding checksums.
46 if test "$indexversion" = "4"
47 then
32 - own=432ef4b63f32193984f339431fd50ca796493569
33 - base=508851a7f0dfa8691e9f69c7f055865389012491
48 + own=$(test_oid own_v4)
49 + base=$(test_oid base_v4)
50 else
35 - own=8299b0bcd1ac364e5f1d7768efb62fa2da79a339
36 - base=39d890139ee5356c7ef572216cebcd27aa41f9df
51 + own=$(test_oid own_v3)
52 + base=$(test_oid base_v3)
53 fi &&
54
55 cat >expect <<-EOF &&
@@ -99,17 +115,18 @@ test_expect_success 'enable split index again, "one" now belongs to base index"'
115
116 test_expect_success 'modify original file, base index untouched' '
117 echo modified | create_non_racy_file one &&
118 + file1_blob=$(git hash-object one) &&
119 git update-index one &&
120 git ls-files --stage >ls-files.actual &&
121 cat >ls-files.expect <<-EOF &&
105 - 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0 one
122 + 100644 $file1_blob 0 one
123 EOF
124 test_cmp ls-files.expect ls-files.actual &&
125
126 test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
127 q_to_tab >expect <<-EOF &&
128 $BASE
112 - 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
129 + 100644 $file1_blob 0Q
130 replacements: 0
131 deletions:
132 EOF
@@ -121,7 +138,7 @@ test_expect_success 'add another file, which stays index' '
138 git update-index --add two &&
139 git ls-files --stage >ls-files.actual &&
140 cat >ls-files.expect <<-EOF &&
124 - 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0 one
141 + 100644 $file1_blob 0 one
142 100644 $EMPTY_BLOB 0 two
143 EOF
144 test_cmp ls-files.expect ls-files.actual &&
@@ -129,7 +146,7 @@ test_expect_success 'add another file, which stays index' '
146 test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
147 q_to_tab >expect <<-EOF &&
148 $BASE
132 - 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
149 + 100644 $file1_blob 0Q
150 100644 $EMPTY_BLOB 0 two
151 replacements: 0
152 deletions:
@@ -141,14 +158,14 @@ test_expect_success 'remove file not in base index' '
158 git update-index --force-remove two &&
159 git ls-files --stage >ls-files.actual &&
160 cat >ls-files.expect <<-EOF &&
144 - 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0 one
161 + 100644 $file1_blob 0 one
162 EOF
163 test_cmp ls-files.expect ls-files.actual &&
164
165 test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
166 q_to_tab >expect <<-EOF &&
167 $BASE
151 - 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
168 + 100644 $file1_blob 0Q
169 replacements: 0
170 deletions:
171 EOF
@@ -237,9 +254,9 @@ test_expect_success 'set core.splitIndex config variable to true' '
254 git update-index --add three &&
255 git ls-files --stage >ls-files.actual &&
256 cat >ls-files.expect <<-EOF &&
240 - 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
241 - 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 three
242 - 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two
257 + 100644 $EMPTY_BLOB 0 one
258 + 100644 $EMPTY_BLOB 0 three
259 + 100644 $EMPTY_BLOB 0 two
260 EOF
261 test_cmp ls-files.expect ls-files.actual &&
262 BASE=$(test-tool dump-split-index .git/index | grep "^base") &&
@@ -257,8 +274,8 @@ test_expect_success 'set core.splitIndex config variable to false' '
274 git update-index --force-remove three &&
275 git ls-files --stage >ls-files.actual &&
276 cat >ls-files.expect <<-EOF &&
260 - 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
261 - 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two
277 + 100644 $EMPTY_BLOB 0 one
278 + 100644 $EMPTY_BLOB 0 two
279 EOF
280 test_cmp ls-files.expect ls-files.actual &&
281 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' '
302 test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
303 cat >expect <<-EOF &&
304 $BASE
288 - 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 four
305 + 100644 $EMPTY_BLOB 0 four
306 replacements:
307 deletions:
308 EOF
@@ -309,7 +326,7 @@ test_expect_success 'check behavior with splitIndex.maxPercentChange unset' '
326 test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
327 cat >expect <<-EOF &&
328 $BASE
312 - 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 six
329 + 100644 $EMPTY_BLOB 0 six
330 replacements:
331 deletions:
332 EOF