Skip to content

Commit 831279d

Browse files
bk2204gitster
authored andcommitted
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 <[email protected]> Reviewed-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b6e5005 commit 831279d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

t/t9350-fast-export.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ test_expect_success 'reencoding iso-8859-7' '
132132
sed "s/wer/i18n/" iso-8859-7.fi |
133133
(cd new &&
134134
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.
136136
# Removing the "encoding iso-8859-7\n" header drops 20 bytes.
137137
# Re-encoding the Pi character from \xF0 (\360) in iso-8859-7
138138
# to \xCF\x80 (\317\200) in UTF-8 adds a byte. Check for
139139
# the expected size.
140-
test 221 -eq "$(git cat-file -s i18n)" &&
140+
test $(($(test_oid hexsz) + 181)) -eq "$(git cat-file -s i18n)" &&
141141
# ...and for the expected translation of bytes.
142142
git cat-file commit i18n >actual &&
143143
grep $(printf "\317\200") actual &&
@@ -164,12 +164,12 @@ test_expect_success 'preserving iso-8859-7' '
164164
sed "s/wer/i18n-no-recoding/" iso-8859-7.fi |
165165
(cd new &&
166166
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.
168168
# Removing the "encoding iso-8859-7\n" header would drops 20
169169
# bytes. Re-encoding the Pi character from \xF0 (\360) in
170170
# iso-8859-7 to \xCF\x80 (\317\200) in UTF-8 adds a byte.
171171
# 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)" &&
173173
# ...as well as the expected byte.
174174
git cat-file commit i18n-no-recoding >actual &&
175175
grep $(printf "\360") actual &&
@@ -192,7 +192,7 @@ test_expect_success 'encoding preserved if reencoding fails' '
192192
grep ^encoding actual &&
193193
# Verify that the commit has the expected size; i.e.
194194
# 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)" &&
196196
# ...and check for the original special bytes
197197
grep $(printf "\360") actual &&
198198
grep $(printf "\377") actual)
@@ -694,7 +694,7 @@ test_expect_success 'delete ref because entire history excluded' '
694694
git fast-export to-delete ^to-delete >actual &&
695695
cat >expected <<-EOF &&
696696
reset refs/heads/to-delete
697-
from 0000000000000000000000000000000000000000
697+
from $ZERO_OID
698698
699699
EOF
700700
test_cmp expected actual
@@ -704,7 +704,7 @@ test_expect_success 'delete refspec' '
704704
git fast-export --refspec :refs/heads/to-delete >actual &&
705705
cat >expected <<-EOF &&
706706
reset refs/heads/to-delete
707-
from 0000000000000000000000000000000000000000
707+
from $ZERO_OID
708708
709709
EOF
710710
test_cmp expected actual

0 commit comments

Comments
 (0)