Skip to content

Commit e483e14

Browse files
bk2204gitster
authored andcommitted
t0000: update tests for SHA-256
Test t0000 tests the "basics of the basics" and as such, checks that we have various fixed hard-coded object IDs. The tests relying on these assertions have been marked with the SHA1 prerequisite, as they will obviously not function in their current form with SHA-256. Use the test_oid helper to update these assertions and provide values for both SHA-1 and SHA-256. These object IDs were synthesized using a set of scripts that created the objects for both SHA-1 and SHA-256 using the same method to ensure that they are indeed the correct values. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cdd1e17 commit e483e14

File tree

1 file changed

+102
-61
lines changed

1 file changed

+102
-61
lines changed

t/t0000-basic.sh

Lines changed: 102 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,47 @@ test_expect_success 'test_oid can look up data for SHA-256' '
861861
################################################################
862862
# Basics of the basics
863863

864+
test_oid_cache <<\EOF
865+
path0f sha1:f87290f8eb2cbbea7857214459a0739927eab154
866+
path0f sha256:638106af7c38be056f3212cbd7ac65bc1bac74f420ca5a436ff006a9d025d17d
867+
868+
path0s sha1:15a98433ae33114b085f3eb3bb03b832b3180a01
869+
path0s sha256:3a24cc53cf68edddac490bbf94a418a52932130541361f685df685e41dd6c363
870+
871+
path2f sha1:3feff949ed00a62d9f7af97c15cd8a30595e7ac7
872+
path2f sha256:2a7f36571c6fdbaf0e3f62751a0b25a3f4c54d2d1137b3f4af9cb794bb498e5f
873+
874+
path2s sha1:d8ce161addc5173867a3c3c730924388daedbc38
875+
path2s sha256:18fd611b787c2e938ddcc248fabe4d66a150f9364763e9ec133dd01d5bb7c65a
876+
877+
path2d sha1:58a09c23e2ca152193f2786e06986b7b6712bdbe
878+
path2d sha256:00e4b32b96e7e3d65d79112dcbea53238a22715f896933a62b811377e2650c17
879+
880+
path3f sha1:0aa34cae68d0878578ad119c86ca2b5ed5b28376
881+
path3f sha256:09f58616b951bd571b8cb9dc76d372fbb09ab99db2393f5ab3189d26c45099ad
882+
883+
path3s sha1:8599103969b43aff7e430efea79ca4636466794f
884+
path3s sha256:fce1aed087c053306f3f74c32c1a838c662bbc4551a7ac2420f5d6eb061374d0
885+
886+
path3d sha1:21ae8269cacbe57ae09138dcc3a2887f904d02b3
887+
path3d sha256:9b60497be959cb830bf3f0dc82bcc9ad9e925a24e480837ade46b2295e47efe1
888+
889+
subp3f sha1:00fb5908cb97c2564a9783c0c64087333b3b464f
890+
subp3f sha256:a1a9e16998c988453f18313d10375ee1d0ddefe757e710dcae0d66aa1e0c58b3
891+
892+
subp3s sha1:6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c
893+
subp3s sha256:81759d9f5e93c6546ecfcadb560c1ff057314b09f93fe8ec06e2d8610d34ef10
894+
895+
subp3d sha1:3c5e5399f3a333eddecce7a9b9465b63f65f51e2
896+
subp3d sha256:76b4ef482d4fa1c754390344cf3851c7f883b27cf9bc999c6547928c46aeafb7
897+
898+
root sha1:087704a96baf1c2d1c869a8b084481e121c88b5b
899+
root sha256:9481b52abab1b2ffeedbf9de63ce422b929f179c1b98ff7bee5f8f1bc0710751
900+
901+
simpletree sha1:7bb943559a305bdd6bdee2cef6e5df2413c3d30a
902+
simpletree sha256:1710c07a6c86f9a3c7376364df04c47ee39e5a5e221fcdd84b743bc9bb7e2bc5
903+
EOF
904+
864905
# updating a new file without --add should fail.
865906
test_expect_success 'git update-index without --add should fail adding' '
866907
test_must_fail git update-index should-be-empty
@@ -876,8 +917,8 @@ test_expect_success 'writing tree out with git write-tree' '
876917
'
877918

878919
# we know the shape and contents of the tree and know the object ID for it.
879-
test_expect_success SHA1 'validate object ID of a known tree' '
880-
test "$tree" = 7bb943559a305bdd6bdee2cef6e5df2413c3d30a
920+
test_expect_success 'validate object ID of a known tree' '
921+
test "$tree" = "$(test_oid simpletree)"
881922
'
882923

883924
# Removing paths.
@@ -919,16 +960,16 @@ test_expect_success 'showing stage with git ls-files --stage' '
919960
git ls-files --stage >current
920961
'
921962

922-
test_expect_success SHA1 'validate git ls-files output for a known tree' '
923-
cat >expected <<-\EOF &&
924-
100644 f87290f8eb2cbbea7857214459a0739927eab154 0 path0
925-
120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0 path0sym
926-
100644 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 0 path2/file2
927-
120000 d8ce161addc5173867a3c3c730924388daedbc38 0 path2/file2sym
928-
100644 0aa34cae68d0878578ad119c86ca2b5ed5b28376 0 path3/file3
929-
120000 8599103969b43aff7e430efea79ca4636466794f 0 path3/file3sym
930-
100644 00fb5908cb97c2564a9783c0c64087333b3b464f 0 path3/subp3/file3
931-
120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0 path3/subp3/file3sym
963+
test_expect_success 'validate git ls-files output for a known tree' '
964+
cat >expected <<-EOF &&
965+
100644 $(test_oid path0f) 0 path0
966+
120000 $(test_oid path0s) 0 path0sym
967+
100644 $(test_oid path2f) 0 path2/file2
968+
120000 $(test_oid path2s) 0 path2/file2sym
969+
100644 $(test_oid path3f) 0 path3/file3
970+
120000 $(test_oid path3s) 0 path3/file3sym
971+
100644 $(test_oid subp3f) 0 path3/subp3/file3
972+
120000 $(test_oid subp3s) 0 path3/subp3/file3sym
932973
EOF
933974
test_cmp expected current
934975
'
@@ -937,20 +978,20 @@ test_expect_success 'writing tree out with git write-tree' '
937978
tree=$(git write-tree)
938979
'
939980

940-
test_expect_success SHA1 'validate object ID for a known tree' '
941-
test "$tree" = 087704a96baf1c2d1c869a8b084481e121c88b5b
981+
test_expect_success 'validate object ID for a known tree' '
982+
test "$tree" = "$(test_oid root)"
942983
'
943984

944985
test_expect_success 'showing tree with git ls-tree' '
945986
git ls-tree $tree >current
946987
'
947988

948-
test_expect_success SHA1 'git ls-tree output for a known tree' '
949-
cat >expected <<-\EOF &&
950-
100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0
951-
120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym
952-
040000 tree 58a09c23e2ca152193f2786e06986b7b6712bdbe path2
953-
040000 tree 21ae8269cacbe57ae09138dcc3a2887f904d02b3 path3
989+
test_expect_success 'git ls-tree output for a known tree' '
990+
cat >expected <<-EOF &&
991+
100644 blob $(test_oid path0f) path0
992+
120000 blob $(test_oid path0s) path0sym
993+
040000 tree $(test_oid path2d) path2
994+
040000 tree $(test_oid path3d) path3
954995
EOF
955996
test_cmp expected current
956997
'
@@ -961,16 +1002,16 @@ test_expect_success 'showing tree with git ls-tree -r' '
9611002
git ls-tree -r $tree >current
9621003
'
9631004

964-
test_expect_success SHA1 'git ls-tree -r output for a known tree' '
965-
cat >expected <<-\EOF &&
966-
100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0
967-
120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym
968-
100644 blob 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 path2/file2
969-
120000 blob d8ce161addc5173867a3c3c730924388daedbc38 path2/file2sym
970-
100644 blob 0aa34cae68d0878578ad119c86ca2b5ed5b28376 path3/file3
971-
120000 blob 8599103969b43aff7e430efea79ca4636466794f path3/file3sym
972-
100644 blob 00fb5908cb97c2564a9783c0c64087333b3b464f path3/subp3/file3
973-
120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c path3/subp3/file3sym
1005+
test_expect_success 'git ls-tree -r output for a known tree' '
1006+
cat >expected <<-EOF &&
1007+
100644 blob $(test_oid path0f) path0
1008+
120000 blob $(test_oid path0s) path0sym
1009+
100644 blob $(test_oid path2f) path2/file2
1010+
120000 blob $(test_oid path2s) path2/file2sym
1011+
100644 blob $(test_oid path3f) path3/file3
1012+
120000 blob $(test_oid path3s) path3/file3sym
1013+
100644 blob $(test_oid subp3f) path3/subp3/file3
1014+
120000 blob $(test_oid subp3s) path3/subp3/file3sym
9741015
EOF
9751016
test_cmp expected current
9761017
'
@@ -980,19 +1021,19 @@ test_expect_success 'showing tree with git ls-tree -r -t' '
9801021
git ls-tree -r -t $tree >current
9811022
'
9821023

983-
test_expect_success SHA1 'git ls-tree -r output for a known tree' '
984-
cat >expected <<-\EOF &&
985-
100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0
986-
120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym
987-
040000 tree 58a09c23e2ca152193f2786e06986b7b6712bdbe path2
988-
100644 blob 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 path2/file2
989-
120000 blob d8ce161addc5173867a3c3c730924388daedbc38 path2/file2sym
990-
040000 tree 21ae8269cacbe57ae09138dcc3a2887f904d02b3 path3
991-
100644 blob 0aa34cae68d0878578ad119c86ca2b5ed5b28376 path3/file3
992-
120000 blob 8599103969b43aff7e430efea79ca4636466794f path3/file3sym
993-
040000 tree 3c5e5399f3a333eddecce7a9b9465b63f65f51e2 path3/subp3
994-
100644 blob 00fb5908cb97c2564a9783c0c64087333b3b464f path3/subp3/file3
995-
120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c path3/subp3/file3sym
1024+
test_expect_success 'git ls-tree -r output for a known tree' '
1025+
cat >expected <<-EOF &&
1026+
100644 blob $(test_oid path0f) path0
1027+
120000 blob $(test_oid path0s) path0sym
1028+
040000 tree $(test_oid path2d) path2
1029+
100644 blob $(test_oid path2f) path2/file2
1030+
120000 blob $(test_oid path2s) path2/file2sym
1031+
040000 tree $(test_oid path3d) path3
1032+
100644 blob $(test_oid path3f) path3/file3
1033+
120000 blob $(test_oid path3s) path3/file3sym
1034+
040000 tree $(test_oid subp3d) path3/subp3
1035+
100644 blob $(test_oid subp3f) path3/subp3/file3
1036+
120000 blob $(test_oid subp3s) path3/subp3/file3sym
9961037
EOF
9971038
test_cmp expected current
9981039
'
@@ -1001,16 +1042,16 @@ test_expect_success 'writing partial tree out with git write-tree --prefix' '
10011042
ptree=$(git write-tree --prefix=path3)
10021043
'
10031044

1004-
test_expect_success SHA1 'validate object ID for a known tree' '
1005-
test "$ptree" = 21ae8269cacbe57ae09138dcc3a2887f904d02b3
1045+
test_expect_success 'validate object ID for a known tree' '
1046+
test "$ptree" = $(test_oid path3d)
10061047
'
10071048

10081049
test_expect_success 'writing partial tree out with git write-tree --prefix' '
10091050
ptree=$(git write-tree --prefix=path3/subp3)
10101051
'
10111052

1012-
test_expect_success SHA1 'validate object ID for a known tree' '
1013-
test "$ptree" = 3c5e5399f3a333eddecce7a9b9465b63f65f51e2
1053+
test_expect_success 'validate object ID for a known tree' '
1054+
test "$ptree" = $(test_oid subp3d)
10141055
'
10151056

10161057
test_expect_success 'put invalid objects into the index' '
@@ -1044,16 +1085,16 @@ test_expect_success 'git read-tree followed by write-tree should be idempotent'
10441085
test "$newtree" = "$tree"
10451086
'
10461087

1047-
test_expect_success SHA1 'validate git diff-files output for a know cache/work tree state' '
1048-
cat >expected <<\EOF &&
1049-
:100644 100644 f87290f8eb2cbbea7857214459a0739927eab154 0000000000000000000000000000000000000000 M path0
1050-
:120000 120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0000000000000000000000000000000000000000 M path0sym
1051-
:100644 100644 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 0000000000000000000000000000000000000000 M path2/file2
1052-
:120000 120000 d8ce161addc5173867a3c3c730924388daedbc38 0000000000000000000000000000000000000000 M path2/file2sym
1053-
:100644 100644 0aa34cae68d0878578ad119c86ca2b5ed5b28376 0000000000000000000000000000000000000000 M path3/file3
1054-
:120000 120000 8599103969b43aff7e430efea79ca4636466794f 0000000000000000000000000000000000000000 M path3/file3sym
1055-
:100644 100644 00fb5908cb97c2564a9783c0c64087333b3b464f 0000000000000000000000000000000000000000 M path3/subp3/file3
1056-
:120000 120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0000000000000000000000000000000000000000 M path3/subp3/file3sym
1088+
test_expect_success 'validate git diff-files output for a know cache/work tree state' '
1089+
cat >expected <<EOF &&
1090+
:100644 100644 $(test_oid path0f) $ZERO_OID M path0
1091+
:120000 120000 $(test_oid path0s) $ZERO_OID M path0sym
1092+
:100644 100644 $(test_oid path2f) $ZERO_OID M path2/file2
1093+
:120000 120000 $(test_oid path2s) $ZERO_OID M path2/file2sym
1094+
:100644 100644 $(test_oid path3f) $ZERO_OID M path3/file3
1095+
:120000 120000 $(test_oid path3s) $ZERO_OID M path3/file3sym
1096+
:100644 100644 $(test_oid subp3f) $ZERO_OID M path3/subp3/file3
1097+
:120000 120000 $(test_oid subp3s) $ZERO_OID M path3/subp3/file3sym
10571098
EOF
10581099
git diff-files >current &&
10591100
test_cmp current expected
@@ -1069,23 +1110,23 @@ test_expect_success 'no diff after checkout and git update-index --refresh' '
10691110
'
10701111

10711112
################################################################
1072-
P=087704a96baf1c2d1c869a8b084481e121c88b5b
1113+
P=$(test_oid root)
10731114

1074-
test_expect_success SHA1 'git commit-tree records the correct tree in a commit' '
1115+
test_expect_success 'git commit-tree records the correct tree in a commit' '
10751116
commit0=$(echo NO | git commit-tree $P) &&
10761117
tree=$(git show --pretty=raw $commit0 |
10771118
sed -n -e "s/^tree //p" -e "/^author /q") &&
10781119
test "z$tree" = "z$P"
10791120
'
10801121

1081-
test_expect_success SHA1 'git commit-tree records the correct parent in a commit' '
1122+
test_expect_success 'git commit-tree records the correct parent in a commit' '
10821123
commit1=$(echo NO | git commit-tree $P -p $commit0) &&
10831124
parent=$(git show --pretty=raw $commit1 |
10841125
sed -n -e "s/^parent //p" -e "/^author /q") &&
10851126
test "z$commit0" = "z$parent"
10861127
'
10871128

1088-
test_expect_success SHA1 'git commit-tree omits duplicated parent in a commit' '
1129+
test_expect_success 'git commit-tree omits duplicated parent in a commit' '
10891130
commit2=$(echo NO | git commit-tree $P -p $commit0 -p $commit0) &&
10901131
parent=$(git show --pretty=raw $commit2 |
10911132
sed -n -e "s/^parent //p" -e "/^author /q" |

0 commit comments

Comments
 (0)