@matheusbsbs / matheus-bagliano / commits / 831279d3c1
Fork 0

t9350: make hash size independent

This test checks for several commit object sizes to verify that objects are encoded as expected. However, the size of a commit object differs between SHA-1 and SHA-256, since each contains a hex representation of the tree's object ID. Since these are root commits, compute the size of each commit by using a constant plus the size of a single hex object ID. In addition, use $ZERO_OID instead of a hard-coded object ID. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Reviewed-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Jul 29, 2020 at 23:14 UTC 831279d3c18694e69a594767b7cc6a88af987cde
1 file changed +7 -7
t/t9350-fast-export.sh
+7 -7
@@ -132,12 +132,12 @@ test_expect_success 'reencoding iso-8859-7' '
132 sed "s/wer/i18n/" iso-8859-7.fi |
133 (cd new &&
134 git fast-import &&
135 - # The commit object, if not re-encoded, would be 240 bytes.
135 + # The commit object, if not re-encoded, would be 200 bytes plus hash.
136 # Removing the "encoding iso-8859-7\n" header drops 20 bytes.
137 # Re-encoding the Pi character from \xF0 (\360) in iso-8859-7
138 # to \xCF\x80 (\317\200) in UTF-8 adds a byte. Check for
139 # the expected size.
140 - test 221 -eq "$(git cat-file -s i18n)" &&
140 + test $(($(test_oid hexsz) + 181)) -eq "$(git cat-file -s i18n)" &&
141 # ...and for the expected translation of bytes.
142 git cat-file commit i18n >actual &&
143 grep $(printf "\317\200") actual &&
@@ -164,12 +164,12 @@ test_expect_success 'preserving iso-8859-7' '
164 sed "s/wer/i18n-no-recoding/" iso-8859-7.fi |
165 (cd new &&
166 git fast-import &&
167 - # The commit object, if not re-encoded, is 240 bytes.
167 + # The commit object, if not re-encoded, is 200 bytes plus hash.
168 # Removing the "encoding iso-8859-7\n" header would drops 20
169 # bytes. Re-encoding the Pi character from \xF0 (\360) in
170 # iso-8859-7 to \xCF\x80 (\317\200) in UTF-8 adds a byte.
171 # Check for the expected size...
172 - test 240 -eq "$(git cat-file -s i18n-no-recoding)" &&
172 + test $(($(test_oid hexsz) + 200)) -eq "$(git cat-file -s i18n-no-recoding)" &&
173 # ...as well as the expected byte.
174 git cat-file commit i18n-no-recoding >actual &&
175 grep $(printf "\360") actual &&
@@ -192,7 +192,7 @@ test_expect_success 'encoding preserved if reencoding fails' '
192 grep ^encoding actual &&
193 # Verify that the commit has the expected size; i.e.
194 # that no bytes were re-encoded to a different encoding.
195 - test 252 -eq "$(git cat-file -s i18n-invalid)" &&
195 + test $(($(test_oid hexsz) + 212)) -eq "$(git cat-file -s i18n-invalid)" &&
196 # ...and check for the original special bytes
197 grep $(printf "\360") actual &&
198 grep $(printf "\377") actual)
@@ -694,7 +694,7 @@ test_expect_success 'delete ref because entire history excluded' '
694 git fast-export to-delete ^to-delete >actual &&
695 cat >expected <<-EOF &&
696 reset refs/heads/to-delete
697 - from 0000000000000000000000000000000000000000
697 + from $ZERO_OID
698
699 EOF
700 test_cmp expected actual
@@ -704,7 +704,7 @@ test_expect_success 'delete refspec' '
704 git fast-export --refspec :refs/heads/to-delete >actual &&
705 cat >expected <<-EOF &&
706 reset refs/heads/to-delete
707 - from 0000000000000000000000000000000000000000
707 + from $ZERO_OID
708
709 EOF
710 test_cmp expected actual