Skip to content

Commit bfefd52

Browse files
bk2204gitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2e306f6 commit bfefd52

File tree

1 file changed

+34
-17
lines changed

1 file changed

+34
-17
lines changed

t/t1700-split-index.sh

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@ create_non_racy_file () {
2020
test-tool chmtime =-5 "$1"
2121
}
2222

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+
2339
test_expect_success 'enable split index' '
2440
git config splitIndex.maxPercentChange 100 &&
2541
git update-index --split-index &&
@@ -29,11 +45,11 @@ test_expect_success 'enable split index' '
2945
# NEEDSWORK: Stop hard-coding checksums.
3046
if test "$indexversion" = "4"
3147
then
32-
own=432ef4b63f32193984f339431fd50ca796493569
33-
base=508851a7f0dfa8691e9f69c7f055865389012491
48+
own=$(test_oid own_v4)
49+
base=$(test_oid base_v4)
3450
else
35-
own=8299b0bcd1ac364e5f1d7768efb62fa2da79a339
36-
base=39d890139ee5356c7ef572216cebcd27aa41f9df
51+
own=$(test_oid own_v3)
52+
base=$(test_oid base_v3)
3753
fi &&
3854
3955
cat >expect <<-EOF &&
@@ -99,17 +115,18 @@ test_expect_success 'enable split index again, "one" now belongs to base index"'
99115

100116
test_expect_success 'modify original file, base index untouched' '
101117
echo modified | create_non_racy_file one &&
118+
file1_blob=$(git hash-object one) &&
102119
git update-index one &&
103120
git ls-files --stage >ls-files.actual &&
104121
cat >ls-files.expect <<-EOF &&
105-
100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0 one
122+
100644 $file1_blob 0 one
106123
EOF
107124
test_cmp ls-files.expect ls-files.actual &&
108125
109126
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
110127
q_to_tab >expect <<-EOF &&
111128
$BASE
112-
100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
129+
100644 $file1_blob 0Q
113130
replacements: 0
114131
deletions:
115132
EOF
@@ -121,15 +138,15 @@ test_expect_success 'add another file, which stays index' '
121138
git update-index --add two &&
122139
git ls-files --stage >ls-files.actual &&
123140
cat >ls-files.expect <<-EOF &&
124-
100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0 one
141+
100644 $file1_blob 0 one
125142
100644 $EMPTY_BLOB 0 two
126143
EOF
127144
test_cmp ls-files.expect ls-files.actual &&
128145
129146
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
130147
q_to_tab >expect <<-EOF &&
131148
$BASE
132-
100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
149+
100644 $file1_blob 0Q
133150
100644 $EMPTY_BLOB 0 two
134151
replacements: 0
135152
deletions:
@@ -141,14 +158,14 @@ test_expect_success 'remove file not in base index' '
141158
git update-index --force-remove two &&
142159
git ls-files --stage >ls-files.actual &&
143160
cat >ls-files.expect <<-EOF &&
144-
100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0 one
161+
100644 $file1_blob 0 one
145162
EOF
146163
test_cmp ls-files.expect ls-files.actual &&
147164
148165
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
149166
q_to_tab >expect <<-EOF &&
150167
$BASE
151-
100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
168+
100644 $file1_blob 0Q
152169
replacements: 0
153170
deletions:
154171
EOF
@@ -237,9 +254,9 @@ test_expect_success 'set core.splitIndex config variable to true' '
237254
git update-index --add three &&
238255
git ls-files --stage >ls-files.actual &&
239256
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
243260
EOF
244261
test_cmp ls-files.expect ls-files.actual &&
245262
BASE=$(test-tool dump-split-index .git/index | grep "^base") &&
@@ -257,8 +274,8 @@ test_expect_success 'set core.splitIndex config variable to false' '
257274
git update-index --force-remove three &&
258275
git ls-files --stage >ls-files.actual &&
259276
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
262279
EOF
263280
test_cmp ls-files.expect ls-files.actual &&
264281
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' '
285302
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
286303
cat >expect <<-EOF &&
287304
$BASE
288-
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 four
305+
100644 $EMPTY_BLOB 0 four
289306
replacements:
290307
deletions:
291308
EOF
@@ -309,7 +326,7 @@ test_expect_success 'check behavior with splitIndex.maxPercentChange unset' '
309326
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
310327
cat >expect <<-EOF &&
311328
$BASE
312-
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 six
329+
100644 $EMPTY_BLOB 0 six
313330
replacements:
314331
deletions:
315332
EOF

0 commit comments

Comments
 (0)