From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 921CE1F5B1 for ; Thu, 23 Jul 2020 02:04:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387614AbgGWBKF (ORCPT ); Wed, 22 Jul 2020 21:10:05 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:40498 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387578AbgGWBKB (ORCPT ); Wed, 22 Jul 2020 21:10:01 -0400 Received: from camp.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:b610:a2f0:36c1:12e3]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 4397561012 for ; Thu, 23 Jul 2020 01:10:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1595466600; bh=UaAP0hIH8vxcehmCkzB++tkC53e5f9DbrGFPfaFhQj0=; h=From:To:Subject:Date:In-Reply-To:References:From:Reply-To:Subject: Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc:In-Reply-To: References:Content-Type:Content-Disposition; b=KxW3OlNJfvVRSAukAalFdaNXSXLrEpfy/u1klq6vE5LM413jNNeHKAkWzz+ZMhqNv RotAHsXyfCrnN1ss2v82kNikAiY2QbGxkw9peUZLRnyxsAzYQ6C4wWzMXdr4D9JHpl gapYoh7P0gFFwbnabLyERqY4E7jk313xV6izt61Ir8FdEXJcGS1EKtOfBrnERV9e0u Wy4ZmcwIZc2WDxn5XsW5R1kB6NMPYjjL4uBTeBQ/EiG9iE0/CblhxRqXgwFqxpmYT2 RNQ2Ul/hmlQBoUMYWr2wiLN5T9asAgG/HhBhGUbC8FDR9l0PqfBy7CnlvjltY7wLX3 x0iZDeasvooN7aHr0Nn5cZkyBSi8Hq9Y0+GURYC0ee7zXWQFX/3hf/m9TQhWThbw5I 6YigJJkwaL0fsULuvcsh5VUR1XJmCaNp4JAaS98UQ4cuNn4Gqfb8w/U7itaeqAvfr2 B9pzItzxnNP3apCrXT1xsQS4+YMOu5IXa85MV64ZCcAmIst0h6J From: "brian m. carlson" To: Subject: [PATCH v3 24/39] t9350: make hash size independent Date: Thu, 23 Jul 2020 01:09:28 +0000 Message-Id: <20200723010943.2329634-25-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.28.0.rc1.129.ge9626dbbb9f In-Reply-To: <20200723010943.2329634-1-sandals@crustytoothpaste.net> References: <20200723010943.2329634-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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 --- t/t9350-fast-export.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh index 690c90fb82..ba79db6a17 100755 --- a/t/t9350-fast-export.sh +++ b/t/t9350-fast-export.sh @@ -7,6 +7,7 @@ test_description='git fast-export' . ./test-lib.sh test_expect_success 'setup' ' + test_oid_init && echo break it > file0 && git add file0 && @@ -132,12 +133,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 +165,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 +193,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 +695,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 +705,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