Skip to content

Commit 38ee26b

Browse files
bk2204gitster
authored andcommitted
t4044: update test to work with SHA-256
This test produces pseudo-collisions and tests git diff's behavior with them, and is therefore sensitive to the hash in use. Update the test to compute the collisions for both SHA-1 and SHA-256 using appropriate constants. Move the heredocs inside the setup block so that all of the setup code can be tested for failure. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 37ab8eb commit 38ee26b

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

t/t4044-diff-index-unique-abbrev.sh

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,48 @@
33
test_description='test unique sha1 abbreviation on "index from..to" line'
44
. ./test-lib.sh
55

6-
if ! test_have_prereq SHA1
7-
then
8-
skip_all='not using SHA-1 for objects'
9-
test_done
10-
fi
11-
12-
cat >expect_initial <<EOF
13-
100644 blob 51d2738463ea4ca66f8691c91e33ce64b7d41bb1 foo
14-
EOF
6+
test_expect_success 'setup' '
7+
test_oid_cache <<-EOF &&
8+
val1 sha1:4827
9+
val1 sha256:5664
1510
16-
cat >expect_update <<EOF
17-
100644 blob 51d2738efb4ad8a1e40bed839ab8e116f0a15e47 foo
18-
EOF
11+
val2 sha1:11742
12+
val2 sha256:10625
1913
20-
test_expect_success 'setup' '
21-
echo 4827 > foo &&
14+
hash1 sha1:51d2738463ea4ca66f8691c91e33ce64b7d41bb1
15+
hash1 sha256:ae31dfff0af93b2c62b0098a039b38569c43b0a7e97b873000ca42d128f27350
16+
17+
hasht1 sha1:51d27384
18+
hasht1 sha256:ae31dfff
19+
20+
hash2 sha1:51d2738efb4ad8a1e40bed839ab8e116f0a15e47
21+
hash2 sha256:ae31dffada88a46fd5f53c7ed5aa25a7a8951f1d5e88456c317c8d5484d263e5
22+
23+
hasht2 sha1:51d2738e
24+
hasht2 sha256:ae31dffa
25+
EOF
26+
27+
cat >expect_initial <<-EOF &&
28+
100644 blob $(test_oid hash1) foo
29+
EOF
30+
31+
cat >expect_update <<-EOF &&
32+
100644 blob $(test_oid hash2) foo
33+
EOF
34+
35+
echo "$(test_oid val1)" > foo &&
2236
git add foo &&
2337
git commit -m "initial" &&
2438
git cat-file -p HEAD: > actual &&
2539
test_cmp expect_initial actual &&
26-
echo 11742 > foo &&
40+
echo "$(test_oid val2)" > foo &&
2741
git commit -a -m "update" &&
2842
git cat-file -p HEAD: > actual &&
2943
test_cmp expect_update actual
3044
'
3145

3246
cat >expect <<EOF
33-
index 51d27384..51d2738e 100644
47+
index $(test_oid hasht1)..$(test_oid hasht2) 100644
3448
EOF
3549

3650
test_expect_success 'diff does not produce ambiguous index line' '

0 commit comments

Comments
 (0)