t0000: use hash translation table
authorbrian m. carlson <sandals@crustytoothpaste.net>
Thu, 13 Sep 2018 05:17:32 +0000 (05:17 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 13 Sep 2018 21:15:24 +0000 (14:15 -0700)
If the hash we're using is 32 bytes in size, attempting to insert a
20-byte object name won't work. Since these are synthesized objects
that are almost all zeros, look them up in a translation table.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t0000-basic.sh
index b94221b9512412546cf6678a6b9a2dc0b3b6911b..a9dc53404841130d369c10f820087ea300cfaf81 100755 (executable)
@@ -1015,12 +1015,13 @@ test_expect_success SHA1 'validate object ID for a known tree' '
 
 test_expect_success 'put invalid objects into the index' '
        rm -f .git/index &&
-       cat >badobjects <<-\EOF &&
-       100644 blob 1000000000000000000000000000000000000000    dir/file1
-       100644 blob 2000000000000000000000000000000000000000    dir/file2
-       100644 blob 3000000000000000000000000000000000000000    dir/file3
-       100644 blob 4000000000000000000000000000000000000000    dir/file4
-       100644 blob 5000000000000000000000000000000000000000    dir/file5
+       suffix=$(echo $ZERO_OID | sed -e "s/^.//") &&
+       cat >badobjects <<-EOF &&
+       100644 blob $(test_oid 001)     dir/file1
+       100644 blob $(test_oid 002)     dir/file2
+       100644 blob $(test_oid 003)     dir/file3
+       100644 blob $(test_oid 004)     dir/file4
+       100644 blob $(test_oid 005)     dir/file5
        EOF
        git update-index --index-info <badobjects
 '