From patchwork Wed Jul 29 23:13:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11691841 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5E4CD13B6 for ; Wed, 29 Jul 2020 23:14:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 49E0F20809 for ; Wed, 29 Jul 2020 23:14:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (3072-bit key) header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.b="ibWbBOjV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728015AbgG2XOu (ORCPT ); Wed, 29 Jul 2020 19:14:50 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:41044 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726718AbgG2XOt (ORCPT ); Wed, 29 Jul 2020 19:14:49 -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 AA6516079A; Wed, 29 Jul 2020 23:14:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1596064487; bh=/7JY2zYnMWAyizSEiCqVtpsg7RZIoduRK486w/OzXs0=; h=From:To:Cc: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=ibWbBOjVdIKvI6YXeeZ3uPAYjb0VVh6mYLlaX2Yx/KV/lNnEDXZZPtjdjZY1GpDXj EBDPbRxPPmRdfFv4RF2aPkm02RAmmumfTNVRHY4zi4DztRgbk6qRaxXziFir9bArSZ 9GwuZexqRjGPPxHl+yqoU8nwYIwj0eLVCkPEAeS8NeEBv88xG1W0LLoSUfGWNUg6ZY kx/i0leYthTx90NsfA7NW11PKC0l1QYDDBVCwTe2a055te+yQQPBim8GtZK9NKkgEm G4xCi0B/Nokx6r4qqAa9vFV3hrDe1w4ZGN3DDihAr573w1cS/4kpnV5A3baT4x4KCY 19Dxe0XAb3P38V4gYpD+n0kQP+dyZmdmefk6P+Y3jiRxQdIbSW4LxFaCoasbDgTs5H sZChfa8tOr3+qFCiZbFHPzbw7Wjs3kj1cWRbfNGcKbddXO7C1HcZcxC1fk9PySMToF uPVc9KCcTsMIKV9A65paPrmjEt4UGfFd6Q7u43LmyQCynf9Sx1D From: "brian m. carlson" To: Cc: Eric Sunshine Subject: [PATCH v6 04/39] t3404: prepare 'short SHA-1 collision' tests for SHA-256 Date: Wed, 29 Jul 2020 23:13:53 +0000 Message-Id: <20200729231428.3658647-5-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6 In-Reply-To: <20200729231428.3658647-1-sandals@crustytoothpaste.net> References: <20200728233446.3066485-1-sandals@crustytoothpaste.net> <20200729231428.3658647-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin The idea of the magic value "ac4f2ee" in this test is to make the reworded commit `collide2` have the same shortened ID as the commit `collide3`. To port the same idea to the SHA-256 version of Git, we therefore need another magic value that causes the same collision, but this time with the SHA-256 version of the commit IDs. In this patch, we add code guarded by `GIT_TEST_FIND_COLLIDER` to do exactly that. Essentially, a large number of integers is appended to the commit message "collide2" to find such a collision. To make it easier to find such a collision, we reduce the number of digits to 4. As the tests are no longer dependent on SHA-1, we also rename their titles to talk about "commit IDs" instead of "SHA-1s". Signed-off-by: Johannes Schindelin Signed-off-by: brian m. carlson --- t/t3404-rebase-interactive.sh | 49 ++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 4a7d21f898..9744e88760 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -1250,7 +1250,7 @@ test_expect_success 'rebase -i error on commits with \ in message' ' test_expect_code 1 grep " emp" error ' -test_expect_success SHA1 'short SHA-1 setup' ' +test_expect_success 'short commit ID setup' ' test_when_finished "git checkout master" && git checkout --orphan collide && git rm -rf . && @@ -1262,23 +1262,54 @@ test_expect_success SHA1 'short SHA-1 setup' ' ) ' -test_expect_success SHA1 'short SHA-1 collide' ' +if test -n "$GIT_TEST_FIND_COLLIDER" +then + author="$(unset test_tick; test_tick; git var GIT_AUTHOR_IDENT)" + committer="$(unset test_tick; test_tick; git var GIT_COMMITTER_IDENT)" + blob="$(git rev-parse collide2:collide)" + from="$(git rev-parse collide1^0)" + repl="commit refs/heads/collider-&\\n" + repl="${repl}author $author\\ncommitter $committer\\n" + repl="${repl}data <script && + git fast-import