Skip to content

Commit 5af345a

Browse files
committed
Merge branch 'bc/hash-independent-tests-part-8'
Preparation for SHA-256 migration continues. * bc/hash-independent-tests-part-8: (21 commits) t6024: update for SHA-256 t6006: make hash size independent t6000: abstract away SHA-1-specific constants t5703: make test work with SHA-256 t5607: make hash size independent t5318: update for SHA-256 t5515: make test hash independent t5321: make test hash independent t5313: make test hash independent t5309: make test hash independent t5302: make hash size independent t4060: make test work with SHA-256 t4211: add test cases for SHA-256 t4211: move SHA-1-specific test cases into a directory t4013: make test hash independent t3311: make test work with SHA-256 t3310: make test work with SHA-256 t3309: make test work with SHA-256 t3308: make test work with SHA-256 t3206: make hash size independent ...
2 parents 0460c10 + f303765 commit 5af345a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1817
-279
lines changed

t/lib-pack.sh

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ pack_header () {
3535
# have hardcoded some well-known objects. See the case statements below for the
3636
# complete list.
3737
pack_obj () {
38+
test_oid_init
39+
3840
case "$1" in
3941
# empty blob
40-
e69de29bb2d1d6434b8b29ae775ad8c2e48c5391)
42+
$EMPTY_BLOB)
4143
case "$2" in
4244
'')
4345
printf '\060\170\234\003\0\0\0\0\1'
@@ -47,7 +49,7 @@ pack_obj () {
4749
;;
4850

4951
# blob containing "\7\76"
50-
e68fe8129b546b101aee9510c5328e7f21ca1d18)
52+
$(test_oid packlib_7_76))
5153
case "$2" in
5254
'')
5355
printf '\062\170\234\143\267\3\0\0\116\0\106'
@@ -59,11 +61,18 @@ pack_obj () {
5961
printf '\234\143\142\142\142\267\003\0\0\151\0\114'
6062
return
6163
;;
64+
37c8e2c15bb22b912e59b43fd51a4f7e9465ed0b5084c5a1411d991cbe630683)
65+
printf '\165\67\310\342\301\133\262\53\221\56\131' &&
66+
printf '\264\77\325\32\117\176\224\145\355\13\120' &&
67+
printf '\204\305\241\101\35\231\34\276\143\6\203\170' &&
68+
printf '\234\143\142\142\142\267\003\0\0\151\0\114'
69+
return
70+
;;
6271
esac
6372
;;
6473

6574
# blob containing "\7\0"
66-
01d7713666f4de822776c7622c10f1b07de280dc)
75+
$(test_oid packlib_7_0))
6776
case "$2" in
6877
'')
6978
printf '\062\170\234\143\147\0\0\0\20\0\10'
@@ -75,6 +84,13 @@ pack_obj () {
7584
printf '\143\142\142\142\147\0\0\0\53\0\16'
7685
return
7786
;;
87+
5d8e6fc40f2dab00e6983a48523fe57e621f46434cb58dbd4422fba03380d886)
88+
printf '\165\135\216\157\304\17\55\253\0\346\230\72' &&
89+
printf '\110\122\77\345\176\142\37\106\103\114\265' &&
90+
printf '\215\275\104\42\373\240\63\200\330\206\170\234' &&
91+
printf '\143\142\142\142\147\0\0\0\53\0\16'
92+
return
93+
;;
7894
esac
7995
;;
8096
esac
@@ -86,7 +102,7 @@ pack_obj () {
86102
then
87103
echo "$1" | git pack-objects --stdout >pack_obj.tmp &&
88104
size=$(wc -c <pack_obj.tmp) &&
89-
dd if=pack_obj.tmp bs=1 count=$((size - 20 - 12)) skip=12 &&
105+
dd if=pack_obj.tmp bs=1 count=$((size - $(test_oid rawsz) - 12)) skip=12 &&
90106
rm -f pack_obj.tmp
91107
return
92108
fi
@@ -97,7 +113,8 @@ pack_obj () {
97113

98114
# Compute and append pack trailer to "$1"
99115
pack_trailer () {
100-
test-tool sha1 -b <"$1" >trailer.tmp &&
116+
test_oid_init &&
117+
test-tool $(test_oid algo) -b <"$1" >trailer.tmp &&
101118
cat trailer.tmp >>"$1" &&
102119
rm -f trailer.tmp
103120
}
@@ -108,3 +125,11 @@ pack_trailer () {
108125
clear_packs () {
109126
rm -f .git/objects/pack/*
110127
}
128+
129+
test_oid_cache <<-EOF
130+
packlib_7_0 sha1:01d7713666f4de822776c7622c10f1b07de280dc
131+
packlib_7_0 sha256:37c8e2c15bb22b912e59b43fd51a4f7e9465ed0b5084c5a1411d991cbe630683
132+
133+
packlib_7_76 sha1:e68fe8129b546b101aee9510c5328e7f21ca1d18
134+
packlib_7_76 sha256:5d8e6fc40f2dab00e6983a48523fe57e621f46434cb58dbd4422fba03380d886
135+
EOF

t/t3206-range-diff.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ test_expect_success 'setup' '
102102
n3 sha256:3b0a644
103103
n4 sha256:e461653
104104
105+
# mode change
106+
o1 sha1:4d39cb3
107+
o2 sha1:26c107f
108+
o3 sha1:4c1e0f5
109+
o1 sha256:d0dd598
110+
o2 sha256:c4a279e
111+
o3 sha256:78459d7
112+
105113
# added and removed
106114
s1 sha1:096b1ba
107115
s2 sha1:d92e698
@@ -336,7 +344,7 @@ test_expect_success 'renamed file' '
336344
test_expect_success 'file with mode only change' '
337345
git range-diff --no-color --submodule=log topic...mode-only-change >actual &&
338346
sed s/Z/\ /g >expect <<-EOF &&
339-
1: fccce22 ! 1: 4d39cb3 s/4/A/
347+
1: $(test_oid t2) ! 1: $(test_oid o1) s/4/A/
340348
@@ Metadata
341349
ZAuthor: Thomas Rast <[email protected]>
342350
Z
@@ -352,7 +360,7 @@ test_expect_success 'file with mode only change' '
352360
Z 7
353361
+
354362
+ ## other-file (new) ##
355-
2: 147e64e ! 2: 26c107f s/11/B/
363+
2: $(test_oid t3) ! 2: $(test_oid o2) s/11/B/
356364
@@ Metadata
357365
ZAuthor: Thomas Rast <[email protected]>
358366
Z
@@ -368,7 +376,7 @@ test_expect_success 'file with mode only change' '
368376
Z 14
369377
+
370378
+ ## other-file (mode change 100644 => 100755) ##
371-
3: a63e992 = 3: 4c1e0f5 s/12/B/
379+
3: $(test_oid t4) = 3: $(test_oid o3) s/12/B/
372380
EOF
373381
test_cmp expect actual
374382
'

t/t3308-notes-merge.sh

Lines changed: 55 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,34 @@ test_expect_success setup '
2020
git notes add -m "Notes on 3rd commit" 3rd &&
2121
git notes add -m "Notes on 4th commit" 4th &&
2222
# Copy notes to remote-notes
23-
git fetch . refs/notes/*:refs/remote-notes/origin/*
23+
git fetch . refs/notes/*:refs/remote-notes/origin/* &&
24+
25+
test_oid_init &&
26+
test_oid_cache <<-EOF
27+
hash4a sha1:5e93d24084d32e1cb61f7070505b9d2530cca987
28+
hash3a sha1:8366731eeee53787d2bdf8fc1eff7d94757e8da0
29+
hash2a sha1:eede89064cd42441590d6afec6c37b321ada3389
30+
hash1a sha1:daa55ffad6cb99bf64226532147ffcaf5ce8bdd1
31+
hash5b sha1:0f2efbd00262f2fd41dfae33df8765618eeacd99
32+
hash4b sha1:dec2502dac3ea161543f71930044deff93fa945c
33+
hash3b sha1:4069cdb399fd45463ec6eef8e051a16a03592d91
34+
hash2c sha1:d000d30e6ddcfce3a8122c403226a2ce2fd04d9d
35+
hash1c sha1:43add6bd0c8c0bc871ac7991e0f5573cfba27804
36+
hash4d sha1:1f257a3a90328557c452f0817d6cc50c89d315d4
37+
hash3d sha1:05a4927951bcef347f51486575b878b2b60137f2
38+
39+
hash4a sha256:eef876be1d32ac2e2e42240e0429325cec116e55e88cb2969899fac695aa762f
40+
hash3a sha256:cf7cd1bc091d7ba4166a86df864110e42087cd893a5ae96bc50d637e0290939d
41+
hash2a sha256:21ddde7ebce2c285213898cb04deca0fd3209610cf7aaf8222e4e2f45262fae2
42+
hash1a sha256:f9fe0eda16c6027732ed9d4295689a03abd16f893be69b3dcbf4037ddb191921
43+
hash5b sha256:20046f2244577797a9e3d3f790ea9eca4d8a6bafb2a5570bcb0e03aa02ce100b
44+
hash4b sha256:f90563d134c61a95bb88afbd45d48ccc9e919c62aa6fbfcd483302b3e4d8dbcb
45+
hash3b sha256:988f2aca9f2d87e93e6a73197c2bb99560cc44a2f92d18653968f956f01221e0
46+
hash2c sha256:84153b777b4d42827a756c6578dcdb59d8ae5d1360b874fb37c430150c825c26
47+
hash1c sha256:9beb2bc4eef72e4c4087be168a20573e34d993d9ab1883055f23e322afa06567
48+
hash4d sha256:32de39dc06e679a7abb2d4a55ede7709b3124340a4a90aa305971b1c72ac319d
49+
hash3d sha256:fa73b20e41cbb7541c4c81d1535016131dbfbeb05bf6a71f6115e9cad31c7af5
50+
EOF
2451
'
2552

2653
commit_sha1=$(git rev-parse 1st^{commit})
@@ -40,10 +67,10 @@ verify_notes () {
4067
}
4168

4269
cat <<EOF | sort >expect_notes_x
43-
5e93d24084d32e1cb61f7070505b9d2530cca987 $commit_sha4
44-
8366731eeee53787d2bdf8fc1eff7d94757e8da0 $commit_sha3
45-
eede89064cd42441590d6afec6c37b321ada3389 $commit_sha2
46-
daa55ffad6cb99bf64226532147ffcaf5ce8bdd1 $commit_sha1
70+
$(test_oid hash4a) $commit_sha4
71+
$(test_oid hash3a) $commit_sha3
72+
$(test_oid hash2a) $commit_sha2
73+
$(test_oid hash1a) $commit_sha1
4774
EOF
4875

4976
cat >expect_log_x <<EOF
@@ -126,10 +153,10 @@ test_expect_success 'merge previous notes commit (y^ => y) => No-op' '
126153
'
127154

128155
cat <<EOF | sort >expect_notes_y
129-
0f2efbd00262f2fd41dfae33df8765618eeacd99 $commit_sha5
130-
dec2502dac3ea161543f71930044deff93fa945c $commit_sha4
131-
4069cdb399fd45463ec6eef8e051a16a03592d91 $commit_sha3
132-
daa55ffad6cb99bf64226532147ffcaf5ce8bdd1 $commit_sha1
156+
$(test_oid hash5b) $commit_sha5
157+
$(test_oid hash4b) $commit_sha4
158+
$(test_oid hash3b) $commit_sha3
159+
$(test_oid hash1a) $commit_sha1
133160
EOF
134161

135162
cat >expect_log_y <<EOF
@@ -193,11 +220,11 @@ test_expect_success 'merge empty notes ref (z => y)' '
193220
'
194221

195222
cat <<EOF | sort >expect_notes_y
196-
0f2efbd00262f2fd41dfae33df8765618eeacd99 $commit_sha5
197-
dec2502dac3ea161543f71930044deff93fa945c $commit_sha4
198-
4069cdb399fd45463ec6eef8e051a16a03592d91 $commit_sha3
199-
d000d30e6ddcfce3a8122c403226a2ce2fd04d9d $commit_sha2
200-
43add6bd0c8c0bc871ac7991e0f5573cfba27804 $commit_sha1
223+
$(test_oid hash5b) $commit_sha5
224+
$(test_oid hash4b) $commit_sha4
225+
$(test_oid hash3b) $commit_sha3
226+
$(test_oid hash2c) $commit_sha2
227+
$(test_oid hash1c) $commit_sha1
201228
EOF
202229

203230
cat >expect_log_y <<EOF
@@ -231,9 +258,9 @@ test_expect_success 'change notes on other notes ref (y)' '
231258
'
232259

233260
cat <<EOF | sort >expect_notes_x
234-
0f2efbd00262f2fd41dfae33df8765618eeacd99 $commit_sha5
235-
1f257a3a90328557c452f0817d6cc50c89d315d4 $commit_sha4
236-
daa55ffad6cb99bf64226532147ffcaf5ce8bdd1 $commit_sha1
261+
$(test_oid hash5b) $commit_sha5
262+
$(test_oid hash4d) $commit_sha4
263+
$(test_oid hash1a) $commit_sha1
237264
EOF
238265

239266
cat >expect_log_x <<EOF
@@ -262,10 +289,10 @@ test_expect_success 'change notes on notes ref (x)' '
262289
'
263290

264291
cat <<EOF | sort >expect_notes_x
265-
0f2efbd00262f2fd41dfae33df8765618eeacd99 $commit_sha5
266-
1f257a3a90328557c452f0817d6cc50c89d315d4 $commit_sha4
267-
d000d30e6ddcfce3a8122c403226a2ce2fd04d9d $commit_sha2
268-
43add6bd0c8c0bc871ac7991e0f5573cfba27804 $commit_sha1
292+
$(test_oid hash5b) $commit_sha5
293+
$(test_oid hash4d) $commit_sha4
294+
$(test_oid hash2c) $commit_sha2
295+
$(test_oid hash1c) $commit_sha1
269296
EOF
270297

271298
cat >expect_log_x <<EOF
@@ -296,8 +323,8 @@ test_expect_success 'merge y into x => Non-conflicting 3-way merge' '
296323
'
297324

298325
cat <<EOF | sort >expect_notes_w
299-
05a4927951bcef347f51486575b878b2b60137f2 $commit_sha3
300-
d000d30e6ddcfce3a8122c403226a2ce2fd04d9d $commit_sha2
326+
$(test_oid hash3d) $commit_sha3
327+
$(test_oid hash2c) $commit_sha2
301328
EOF
302329

303330
cat >expect_log_w <<EOF
@@ -326,11 +353,11 @@ test_expect_success 'create notes on new, separate notes ref (w)' '
326353
'
327354

328355
cat <<EOF | sort >expect_notes_x
329-
0f2efbd00262f2fd41dfae33df8765618eeacd99 $commit_sha5
330-
1f257a3a90328557c452f0817d6cc50c89d315d4 $commit_sha4
331-
05a4927951bcef347f51486575b878b2b60137f2 $commit_sha3
332-
d000d30e6ddcfce3a8122c403226a2ce2fd04d9d $commit_sha2
333-
43add6bd0c8c0bc871ac7991e0f5573cfba27804 $commit_sha1
356+
$(test_oid hash5b) $commit_sha5
357+
$(test_oid hash4d) $commit_sha4
358+
$(test_oid hash3d) $commit_sha3
359+
$(test_oid hash2c) $commit_sha2
360+
$(test_oid hash1c) $commit_sha1
334361
EOF
335362

336363
cat >expect_log_x <<EOF

0 commit comments

Comments
 (0)