summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2020-07-29 23:14:13 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-07-30 16:16:48 (GMT)
commit831279d3c18694e69a594767b7cc6a88af987cde (patch)
tree22256e202a6d1a77daa711019f932e1295dd3ee3
parentb6e50052ac60254f423762e8a4f6192400130455 (diff)
downloadgit-831279d3c18694e69a594767b7cc6a88af987cde.zip
git-831279d3c18694e69a594767b7cc6a88af987cde.tar.gz
git-831279d3c18694e69a594767b7cc6a88af987cde.tar.bz2
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>
-rwxr-xr-xt/t9350-fast-export.sh14
1 files changed, 7 insertions, 7 deletions
diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh
index 690c90f..1372842 100755
--- a/t/t9350-fast-export.sh
+++ b/t/t9350-fast-export.sh
@@ -132,12 +132,12 @@ test_expect_success 'reencoding iso-8859-7' '
sed "s/wer/i18n/" iso-8859-7.fi |
(cd new &&
git fast-import &&
- # The commit object, if not re-encoded, would be 240 bytes.
+ # The commit object, if not re-encoded, would be 200 bytes plus hash.
# Removing the "encoding iso-8859-7\n" header drops 20 bytes.
# Re-encoding the Pi character from \xF0 (\360) in iso-8859-7
# to \xCF\x80 (\317\200) in UTF-8 adds a byte. Check for
# the expected size.
- test 221 -eq "$(git cat-file -s i18n)" &&
+ test $(($(test_oid hexsz) + 181)) -eq "$(git cat-file -s i18n)" &&
# ...and for the expected translation of bytes.
git cat-file commit i18n >actual &&
grep $(printf "\317\200") actual &&
@@ -164,12 +164,12 @@ test_expect_success 'preserving iso-8859-7' '
sed "s/wer/i18n-no-recoding/" iso-8859-7.fi |
(cd new &&
git fast-import &&
- # The commit object, if not re-encoded, is 240 bytes.
+ # The commit object, if not re-encoded, is 200 bytes plus hash.
# Removing the "encoding iso-8859-7\n" header would drops 20
# bytes. Re-encoding the Pi character from \xF0 (\360) in
# iso-8859-7 to \xCF\x80 (\317\200) in UTF-8 adds a byte.
# Check for the expected size...
- test 240 -eq "$(git cat-file -s i18n-no-recoding)" &&
+ test $(($(test_oid hexsz) + 200)) -eq "$(git cat-file -s i18n-no-recoding)" &&
# ...as well as the expected byte.
git cat-file commit i18n-no-recoding >actual &&
grep $(printf "\360") actual &&
@@ -192,7 +192,7 @@ test_expect_success 'encoding preserved if reencoding fails' '
grep ^encoding actual &&
# Verify that the commit has the expected size; i.e.
# that no bytes were re-encoded to a different encoding.
- test 252 -eq "$(git cat-file -s i18n-invalid)" &&
+ test $(($(test_oid hexsz) + 212)) -eq "$(git cat-file -s i18n-invalid)" &&
# ...and check for the original special bytes
grep $(printf "\360") actual &&
grep $(printf "\377") actual)
@@ -694,7 +694,7 @@ test_expect_success 'delete ref because entire history excluded' '
git fast-export to-delete ^to-delete >actual &&
cat >expected <<-EOF &&
reset refs/heads/to-delete
- from 0000000000000000000000000000000000000000
+ from $ZERO_OID
EOF
test_cmp expected actual
@@ -704,7 +704,7 @@ test_expect_success 'delete refspec' '
git fast-export --refspec :refs/heads/to-delete >actual &&
cat >expected <<-EOF &&
reset refs/heads/to-delete
- from 0000000000000000000000000000000000000000
+ from $ZERO_OID
EOF
test_cmp expected actual