From patchwork Fri Jun 19 22:39:34 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: 11615287 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 62E67913 for ; Fri, 19 Jun 2020 22:52:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 40ED2223C6 for ; Fri, 19 Jun 2020 22:52:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (3072-bit key) header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.b="eKmb6vSD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729813AbgFSWwC (ORCPT ); Fri, 19 Jun 2020 18:52:02 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:39828 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729795AbgFSWwC (ORCPT ); Fri, 19 Jun 2020 18:52:02 -0400 Received: from camp.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:7d4e:cde:7c41:71c2]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id E992160791; Fri, 19 Jun 2020 22:51:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1592607091; bh=GrrbOwxtfZN0cors2SlMO+VoQjRZiEcLyy3X9tGla/0=; 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=eKmb6vSDcRCFxca8aBV4KYxU/XGbkSFJ9SPynXgMAtPaTSu/ps30dapJX7gTG/e4z CF2CpDD8b5R2ZjSPoAQFhf49qkrlgfPofVvxaGlrNdSwTHYCQFHYLt8xR/EUrJcGZX v469zxhEPP26aR9rLVdaqzVRphiDaWG3a1GIar98v/FIJ4+vxUR6t9Wi531pA/aKvV 059UY77BOxLcKpsnESThjZVtYN4GCuBxcGvvNUR0lSA2bJkCi6bhuuCsCZOcUfafMQ X69JMGds6uFPHjXhxgTM69YmL2ftWImCPKveH85Fp0srK7vB+c+3P0PRKeS9Tl08V5 KnWbYX0hC74tiF9sxkMN3nBHZ6E5ib+3Uc2XPbDn+tLfWLsOLIAjEPxeTZ1UjjawbQ +udnj/7oGLROXMw3TAhaoHujnbkZSEFVAp6rAU0gQB9lRWBf1LEUO/syrbyu/Op/zQ dWwwY1xZx7mR5p8LLbQh7G3XNAnIOQfLzWBtcsTZYFTHjYBa+HE From: "brian m. carlson" To: Cc: Matthew DeVore , Eric Wong , Matthieu Moy Subject: [PATCH 01/14] t9109: make test hash independent Date: Fri, 19 Jun 2020 22:39:34 +0000 Message-Id: <20200619223947.947067-2-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.27.0.278.ge193c7cf3a9 In-Reply-To: <20200619223947.947067-1-sandals@crustytoothpaste.net> References: <20200619223947.947067-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 Instead of stripping off the first 41 characters of git log output, let's just strip off the first space-separated component, which will work for any size hash. Signed-off-by: brian m. carlson --- t/t9109-git-svn-multi-glob.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/t/t9109-git-svn-multi-glob.sh b/t/t9109-git-svn-multi-glob.sh index c1e7542a37..648dcee1ea 100755 --- a/t/t9109-git-svn-multi-glob.sh +++ b/t/t9109-git-svn-multi-glob.sh @@ -48,7 +48,7 @@ test_expect_success 'test refspec globbing' ' "tags/*/src/a:refs/remotes/tags/*" && git svn multi-fetch && git log --pretty=oneline refs/remotes/tags/end >actual && - sed -e "s/^.\{41\}//" actual >output.end && + cut -d" " -f2- actual >output.end && test_cmp expect.end output.end && test "$(git rev-parse refs/remotes/tags/end~1)" = \ "$(git rev-parse refs/remotes/branches/v1/start)" && @@ -84,7 +84,7 @@ test_expect_success 'test left-hand-side only globbing' ' test $(git rev-parse refs/remotes/two/tags/end~3) = \ $(git rev-parse refs/remotes/two/branches/v1/start) && git log --pretty=oneline refs/remotes/two/tags/end >actual && - sed -e "s/^.\{41\}//" actual >output.two && + cut -d" " -f2- actual >output.two && test_cmp expect.two output.two ' cat > expect.four <actual && - sed -e "s/^.\{41\}//" actual >output.four && + cut -d" " -f2- actual >output.four && test_cmp expect.four output.four ' From patchwork Fri Jun 19 22:39:35 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: 11615293 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 0456E14DD for ; Fri, 19 Jun 2020 22:52:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E152B223BF for ; Fri, 19 Jun 2020 22:52:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (3072-bit key) header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.b="nAeSGyy0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729818AbgFSWwE (ORCPT ); Fri, 19 Jun 2020 18:52:04 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:39834 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729798AbgFSWwD (ORCPT ); Fri, 19 Jun 2020 18:52:03 -0400 Received: from camp.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:7d4e:cde:7c41:71c2]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 85FFF60A5C; Fri, 19 Jun 2020 22:51:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1592607091; bh=CKXqyLpVG2H0LquA9U6HCRvE2fzakReJAFg20+nBFT0=; 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=nAeSGyy0wF5ndjgBj3PqRxWWJZ9bi933gQMUs8oIDtay77cIeMiMNU3UpxoOQIJSA FkuRG6DaRHetbsuO3vJBG0mhftatbc1qCs2HUfYFzRgsDZ8UvtCSGZj/h3A9oiK/uC 0xjohkE1Mu0ODcmG6xMninNms4GnyyCj+v6+0n2Y70KbxigQZ/MgoADxky62k7tAw4 3O0gt4MM6hlHHqNcJWB+QcMB/TJvyinhbc20o22vsjvmQ4rWCMAS2KtGa27k/asywq LZO5iG/xd6KmK9M7Cu7fg+91kmKI6mYkf9wC9/yGahSBxAAnLXxsGQAGnC0W/POb0N 234dd0fX6NaM2egkdJuWyALjpiLOxluyVCdJlSYplrVD7QzaBDzFGoFKZTZfCxgMAD oBx6P8PI8I/4bsBjXLKp19Qp4nu89MPt2UC3D43dto0xGOySN4H01qmTKHx8+2i0oe UXov13Z5mUEA7TxKd3yzz2dHC+XuIICwf8ZuAv9y6u5GhF215f8 From: "brian m. carlson" To: Cc: Matthew DeVore , Eric Wong , Matthieu Moy Subject: [PATCH 02/14] t9168: make test hash independent Date: Fri, 19 Jun 2020 22:39:35 +0000 Message-Id: <20200619223947.947067-3-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.27.0.278.ge193c7cf3a9 In-Reply-To: <20200619223947.947067-1-sandals@crustytoothpaste.net> References: <20200619223947.947067-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 Instead of stripping off the first 41 characters of git log output, let's just strip off the first space-separated component, which will work for any size hash. Signed-off-by: brian m. carlson --- t/t9168-git-svn-partially-globbed-names.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/t/t9168-git-svn-partially-globbed-names.sh b/t/t9168-git-svn-partially-globbed-names.sh index bdf6e84999..854b3419b2 100755 --- a/t/t9168-git-svn-partially-globbed-names.sh +++ b/t/t9168-git-svn-partially-globbed-names.sh @@ -49,7 +49,7 @@ test_expect_success 'test refspec prefixed globbing' ' "tags/t_*/src/a:refs/remotes/tags/t_*" && git svn multi-fetch && git log --pretty=oneline refs/remotes/tags/t_end >actual && - sed -e "s/^.\{41\}//" actual >output.end && + cut -d" " -f2- actual >output.end && test_cmp expect.end output.end && test "$(git rev-parse refs/remotes/tags/t_end~1)" = \ "$(git rev-parse refs/remotes/branches/b_start)" && @@ -87,7 +87,7 @@ test_expect_success 'test left-hand-side only prefixed globbing' ' test $(git rev-parse refs/remotes/two/tags/t_end~3) = \ $(git rev-parse refs/remotes/two/branches/b_start) && git log --pretty=oneline refs/remotes/two/tags/t_end >actual && - sed -e "s/^.\{41\}//" actual >output.two && + cut -d" " -f2- actual >output.two && test_cmp expect.two output.two ' @@ -129,7 +129,7 @@ test_expect_success 'test prefixed globs match just prefix' ' test $(git rev-parse refs/remotes/three/tags/t_~1) = \ $(git rev-parse refs/remotes/three/branches/b_) && git log --pretty=oneline refs/remotes/three/tags/t_ >actual && - sed -e "s/^.\{41\}//" actual >output.three && + cut -d" " -f2- actual >output.three && test_cmp expect.three output.three ' @@ -199,7 +199,7 @@ test_expect_success 'test globbing in the middle of the word' ' test $(git rev-parse refs/remotes/five/tags/fghij~1) = \ $(git rev-parse refs/remotes/five/branches/abcde) && git log --pretty=oneline refs/remotes/five/tags/fghij >actual && - sed -e "s/^.\{41\}//" actual >output.five && + cut -d" " -f2- actual >output.five && test_cmp expect.five output.five ' From patchwork Fri Jun 19 22:39:36 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: 11615291 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 6A51A13B1 for ; Fri, 19 Jun 2020 22:52:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 47EC1223BF for ; Fri, 19 Jun 2020 22:52:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (3072-bit key) header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.b="LPzAQxSd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729821AbgFSWwF (ORCPT ); Fri, 19 Jun 2020 18:52:05 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:39836 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729746AbgFSWwD (ORCPT ); Fri, 19 Jun 2020 18:52:03 -0400 Received: from camp.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:7d4e:cde:7c41:71c2]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 220B560A5D; Fri, 19 Jun 2020 22:51:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1592607092; bh=UNaknLfYG4icOEWxN86C3aVzA/qpOqPsBJ6F0gMuBZw=; 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=LPzAQxSdl1ZOjXAbNrTfKwjq8Zm4KQgsWfU8LupRROkh1F8hFiO93E1ih5c989wIs lhcxQvCxNJmW5encDlxtLowYE3C9c8vSHrJs1jJIbrrwvaXZymWiGuvFNEiKuPrlSB zuMqDCIBgIOXwRHza67H79u3k5nKgGwAm61t+VcgGeTOrpptdstI6TOZbdkG0ALF8Q elV2IeQf1ccHDfMs2FKL8ZC4Td6nc6978yKazA9QF7wBPrhUEnPaQte5I7evYGDYmg bf+aPT5bYmlWugZmuUTQbaoi8DaEAbXzQw3zwaBz8V1ri01vLpfbeki7dR2RFtPjF0 uJEeZw5fOYJBaQ+LRocefnsO0K8ZlbfPxGxCXIsBHROCyRkQp/ZRSVspde09OCT6LL EMlCBCKoSeAHGSo5r3+Zrw5oAfh8XTM8bXmR0MJf8a6ZcaL6grnQeWoYNM+vnuQHCt Xd13f6SNeLJ/fUq5yFkIgtEeJiOvNYLSGkl8MUG7O5mn+L4FfUm From: "brian m. carlson" To: Cc: Matthew DeVore , Eric Wong , Matthieu Moy Subject: [PATCH 03/14] t9108: make test hash independent Date: Fri, 19 Jun 2020 22:39:36 +0000 Message-Id: <20200619223947.947067-4-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.27.0.278.ge193c7cf3a9 In-Reply-To: <20200619223947.947067-1-sandals@crustytoothpaste.net> References: <20200619223947.947067-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 Instead of stripping off the first 41 characters of git log output, let's just strip off the first space-separated component, which will work for any size hash. Signed-off-by: brian m. carlson --- t/t9108-git-svn-glob.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/t9108-git-svn-glob.sh b/t/t9108-git-svn-glob.sh index 6990f64364..d5939d4753 100755 --- a/t/t9108-git-svn-glob.sh +++ b/t/t9108-git-svn-glob.sh @@ -48,7 +48,7 @@ test_expect_success 'test refspec globbing' ' "tags/*/src/a:refs/remotes/tags/*" && git svn multi-fetch && git log --pretty=oneline refs/remotes/tags/end >actual && - sed -e "s/^.\{41\}//" actual >output.end && + cut -d" " -f2- actual >output.end && test_cmp expect.end output.end && test "$(git rev-parse refs/remotes/tags/end~1)" = \ "$(git rev-parse refs/remotes/branches/start)" && @@ -84,7 +84,7 @@ test_expect_success 'test left-hand-side only globbing' ' test $(git rev-parse refs/remotes/two/tags/end~3) = \ $(git rev-parse refs/remotes/two/branches/start) && git log --pretty=oneline refs/remotes/two/tags/end >actual && - sed -e "s/^.\{41\}//" actual >output.two && + cut -d" " -f2- actual >output.two && test_cmp expect.two output.two ' From patchwork Fri Jun 19 22:39:37 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: 11615269 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 CC38413B1 for ; Fri, 19 Jun 2020 22:51:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B38CC223BF for ; Fri, 19 Jun 2020 22:51:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (3072-bit key) header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.b="hPMSXA3g" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729709AbgFSWve (ORCPT ); Fri, 19 Jun 2020 18:51:34 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:39726 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726900AbgFSWve (ORCPT ); Fri, 19 Jun 2020 18:51:34 -0400 Received: from camp.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:7d4e:cde:7c41:71c2]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id AD00E60A5E; Fri, 19 Jun 2020 22:51:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1592607093; bh=PFwsn2BGLChsioOxqyEXOQRSkXGQIrT4VC6X5k/0YUU=; 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=hPMSXA3g7fxGLxcEYxqXFE9D59D2bB5BytmfgbnsFCT51BsQDySDgwDIYNaaNIzly jjxtT6kQBTE+JSaRu2CCvwcmyCOQrUlcPSSKS5ZL+v3cWQCAgv9dUDhW5i7IfgDZZf f1biL5Db4gl8RJ5Jzyo4Qh/dChLaBI+kRO90D5ECu/8P715DLH6nonjVpywauyeUF9 2tPCFK87kdVrIp/PR/9desFh3nCIxzZsN/MMoUfdJHmz1dBwDqiCsyPIw7rOzUulwf l5Fn7x6lKhBQk2GnlM/eO8kwQTp4GV/vPnbf1OUdMhzCoOMFRCS79ostZnuBjjV1u2 NizBaoOD0571Hh2JiRVCfJ8T2pq/XyJjPSf6QhwTjohg0V7Wz+UKnrrI78ySTPrL5Y ZhQao9gf7nxu0McIasBdwI2t361b/OMLXfgBRS70Ciy2DB97BDUQzz2J4X4mOL+fTS u6YqteyMffDPI1HXV9jtEBXrbH1gqgszNrZnNVyCFe9i2yJ4MNH From: "brian m. carlson" To: Cc: Matthew DeVore , Eric Wong , Matthieu Moy Subject: [PATCH 04/14] t9100: make test work with SHA-256 Date: Fri, 19 Jun 2020 22:39:37 +0000 Message-Id: <20200619223947.947067-5-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.27.0.278.ge193c7cf3a9 In-Reply-To: <20200619223947.947067-1-sandals@crustytoothpaste.net> References: <20200619223947.947067-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 Compute the relevant tree objects for SHA-256 and use those when appropriate instead of using the SHA-1 ones. Signed-off-by: brian m. carlson --- t/t9100-git-svn-basic.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh index 2c309a57d9..9f2d19ecc4 100755 --- a/t/t9100-git-svn-basic.sh +++ b/t/t9100-git-svn-basic.sh @@ -208,9 +208,10 @@ name='check imported tree checksums expected tree checksums' rm -f expected if test_have_prereq UTF8 then - echo tree dc68b14b733e4ec85b04ab6f712340edc5dc936e > expected + echo tree dc68b14b733e4ec85b04ab6f712340edc5dc936e > expected.sha1 + echo tree b95b55b29d771f5eb73aa9b9d52d02fe11a2538c2feb0829f754ce20a91d98eb > expected.sha256 fi -cat >> expected <<\EOF +cat >> expected.sha1 <<\EOF tree c3322890dcf74901f32d216f05c5044f670ce632 tree d3ccd5035feafd17b030c5732e7808cc49122853 tree d03e1630363d4881e68929d532746b20b0986b83 @@ -220,8 +221,20 @@ tree 149d63cd5878155c846e8c55d7d8487de283f89e tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4 EOF +cat >> expected.sha256 <<\EOF +tree 8d12756699d0b5b110514240a0ff141f6cbf8891fd69ab05e5594196fb437c9f +tree 8187168d33f7d4ccb8c1cc6e99532810aaccb47658f35d19b3803072d1128d7a +tree 74e535d85da8ee25eb23d7b506790c5ab3ccdb1ba0826bd57625ed44ef361650 +tree 6fd7dd963e3cdca0cbd6368ed3cfcc8037cc154d2e7719d9d369a0952364fd95 +tree 1fd6cec6aa95102d69266e20419bb62ec2a06372d614b9850ef23ff204103bb4 +tree 6fd7dd963e3cdca0cbd6368ed3cfcc8037cc154d2e7719d9d369a0952364fd95 +tree deb2b7ac79cd8ce6f52af6a5a0a08691e94ba74a2ed55966bb27dbec551730eb +tree 59e2e936761188476a7752034e8aa0a822b34050c8504b0dfd946407f4bc9215 +EOF -test_expect_success POSIXPERM,SYMLINKS "$name" "test_cmp expected a" +test_expect_success POSIXPERM,SYMLINKS "$name" ' + test_cmp expected.$(test_oid algo) a +' test_expect_success 'exit if remote refs are ambigious' ' git config --add svn-remote.svn.fetch \ From patchwork Fri Jun 19 22:39:38 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: 11615271 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 79F5C913 for ; Fri, 19 Jun 2020 22:51:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 52C25223C6 for ; Fri, 19 Jun 2020 22:51:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (3072-bit key) header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.b="xUGcCoK9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729736AbgFSWvg (ORCPT ); Fri, 19 Jun 2020 18:51:36 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:39744 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729714AbgFSWvf (ORCPT ); Fri, 19 Jun 2020 18:51:35 -0400 Received: from camp.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:7d4e:cde:7c41:71c2]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 45B4A60A60; Fri, 19 Jun 2020 22:51:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1592607093; bh=mIcA5gOf7x6V4CtJBabDCzptsnGtuqXE3ouDLrU4xOM=; 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=xUGcCoK9qDUZ0fsclDngr611zFvWpqC2Dm1CpgX1spDl2ffsfFfXrJxx+KF/JIko3 3pxD7GdeDt23NkXNYU9rUP3JaxbR8YWS5ibZNAsLY2GDdI7bvB3Ode+X/t6mn/B7hQ 0qkUW/1DL9sYUqqqy85QZ+qHGtjWmHl1huZ2+gToQnVkiTAFGz7NCuh34CrZbM4tvK Bx6IQZ4kujJ0Jv5acWqtTO4SzeIQgQmbbf0I6M/jLDrIrzFBtfDciYg81VjnCwDdzz JgKpH+TDZuetZ3aH79YzDQgU2IRTIG2M/noPNRBjvroqAUS8+4V8vuXt7QH4m6aPXP Ao/4KllFRQhSiVIucvGyAHKN7+TdT8/nm0mN+M3J8euE+wxGHC/npz2idO45q18ZN/ 2cB7whnlohsKfYEKBJxZXCClAXz+ClyxbCPbeLRxQX6MwJS/Wi2Zemw92600KNdYMN b0vax8t4ShJ5EFBTiU9wmxv4s5AeebhDymr5YEfp+7Xp/s1XnLa From: "brian m. carlson" To: Cc: Matthew DeVore , Eric Wong , Matthieu Moy Subject: [PATCH 05/14] t9104: make hash size independent Date: Fri, 19 Jun 2020 22:39:38 +0000 Message-Id: <20200619223947.947067-6-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.27.0.278.ge193c7cf3a9 In-Reply-To: <20200619223947.947067-1-sandals@crustytoothpaste.net> References: <20200619223947.947067-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 The size of a record in the database used by git svn is four bytes plus the length of the binary hash. Instead of hard-coding 24, compute this value based on the size of the hash in use. Signed-off-by: brian m. carlson --- t/t9104-git-svn-follow-parent.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh index 5e0ad19177..67eed2fefc 100755 --- a/t/t9104-git-svn-follow-parent.sh +++ b/t/t9104-git-svn-follow-parent.sh @@ -161,6 +161,7 @@ test_expect_success "track initial change if it was only made to parent" ' ' test_expect_success "follow-parent is atomic" ' + record_size=$(($(test_oid rawsz) + 4)) && ( cd wc && svn_cmd up && @@ -186,7 +187,7 @@ test_expect_success "follow-parent is atomic" ' mkdir -p "$GIT_DIR"/svn/refs/remotes/flunk@18 && rev_map=$(cd "$GIT_DIR"/svn/refs/remotes/stunk && ls .rev_map*) && dd if="$GIT_DIR"/svn/refs/remotes/stunk/$rev_map \ - of="$GIT_DIR"/svn/refs/remotes/flunk@18/$rev_map bs=24 count=1 && + of="$GIT_DIR"/svn/refs/remotes/flunk@18/$rev_map bs=$record_size count=1 && rm -rf "$GIT_DIR"/svn/refs/remotes/stunk && git svn init --minimize-url -i flunk "$svnrepo"/flunk && git svn fetch -i flunk && From patchwork Fri Jun 19 22:39:39 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: 11615273 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 4F34213B1 for ; Fri, 19 Jun 2020 22:51:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F532223C6 for ; Fri, 19 Jun 2020 22:51:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (3072-bit key) header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.b="f8fDcRty" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729726AbgFSWvg (ORCPT ); Fri, 19 Jun 2020 18:51:36 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:39746 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726900AbgFSWvf (ORCPT ); Fri, 19 Jun 2020 18:51:35 -0400 Received: from camp.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:7d4e:cde:7c41:71c2]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id D107660A62; Fri, 19 Jun 2020 22:51:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1592607094; bh=CQU1uFJvbhgXo5lAz9npfF/EORtng3o9n9vqKrMBAIY=; 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=f8fDcRtySMMSBlfD8LUwCbdzfyIBsGfmXGJanY1jSGhb3qiGGlX4vYYXpxj9hIlxm LYgdUoTlt1GosUqglpR68inrJ4qY5qBLSTz9iIjPWADhJfsR1n9PvDGkD9SMDz+I7K AVM/xHDcp8d8WXL+t/XJ/b2rtebwwwkiPDCsE/tyrB/GINNX9PEoCgRI5HuCYUnFTe YpQwo4QTbKP2JNIsnuB66tARs0XNxfpqDPRUkwdMMguDVwU72a2eUoEDWZ+MSF88BL uwiye9M455OZ0itBdyLYhgM6dPF9eHEk23PEocgBDWg5GO8dMYlLipOUHk0UCc0wVC KU3/Ww0PmdYfYB+2YmtVnj5ut/WtCJ7wnNuvnIJA8h2Ij5G+gH3PvuJOF+oxu+/Pvd KWtOwGY8Q47+1tLJE1lnBC+v1yckrleotRJdXtSSlDpREjsR8pIVRvWDY3YSuVM60o DcqKD/YGlj+r8OrAg9fP0/yy/RyvR+jQKLVkQU9P/KlPasvhSkG From: "brian m. carlson" To: Cc: Matthew DeVore , Eric Wong , Matthieu Moy Subject: [PATCH 06/14] t9101: make hash independent Date: Fri, 19 Jun 2020 22:39:39 +0000 Message-Id: <20200619223947.947067-7-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.27.0.278.ge193c7cf3a9 In-Reply-To: <20200619223947.947067-1-sandals@crustytoothpaste.net> References: <20200619223947.947067-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 Instead of hard-coding the object ID for our test .gitignore file, let's compute it. Signed-off-by: brian m. carlson --- t/t9101-git-svn-props.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh index c26c4b0927..8b5681dd68 100755 --- a/t/t9101-git-svn-props.sh +++ b/t/t9101-git-svn-props.sh @@ -160,11 +160,13 @@ cat >create-ignore.expect <<\EOF /no-such-file* EOF -cat >create-ignore-index.expect <<\EOF -100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 .gitignore -100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 deeply/.gitignore -100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 deeply/nested/.gitignore -100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 deeply/nested/directory/.gitignore +expectoid=$(git hash-object create-ignore.expect) + +cat >create-ignore-index.expect < X-Patchwork-Id: 11615277 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 716C4913 for ; Fri, 19 Jun 2020 22:51:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5774B223C6 for ; Fri, 19 Jun 2020 22:51:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (3072-bit key) header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.b="FqZgYYCP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729770AbgFSWvk (ORCPT ); Fri, 19 Jun 2020 18:51:40 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:39746 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729716AbgFSWvg (ORCPT ); Fri, 19 Jun 2020 18:51:36 -0400 Received: from camp.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:7d4e:cde:7c41:71c2]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 65E9060A67; Fri, 19 Jun 2020 22:51:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1592607094; bh=XDT8JqlrKYZAZ5ln7hANMpFRbcqJsRJdQRDYIzoT3Mo=; 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=FqZgYYCPVcfT60hknpaxMQcuF53HK+PL3MY6jAyV7mxy7UQfgzMzdXczhXbvbDP4r JahAP90Qy2dZBSdsiHkpsZ9Y2uB1sf6GibJAcqRzQlTNeAaySzNZl0kpssXGhdiydz a0gi4gdl4/8SSCO0h/+gZSS7aZTnh9TEI+Na/XVz1Es3+61v1VXhhpBh+ZUWp3OLuH UZRYB0HS8ZsOhIb+QsozSbid6WGX2jjj7YLpXgqBh+TEpiHJiySGG3/VLiBJqXLpYI V+SBiX/443DIFQrKEi7HfbAoLBdZQb2LwfxgAPkQH0CdL/xsAhDowHxZs1N5eViu2T w7hMDs0Du8rCrPWYCJhJ0nZpU1F3Sa+ZOwc8JxZL124RUsggXVe1l0DYIotGw1FbKs 7PuP0L47eXdC80Yb/YGRSQmgfCL8IFwt+RRmoqw2SOu3eV606Id7EKwdZAQM1LGdnd oKpfeFWfi2kqwoxwjWVkOgVD5lXNAwCky8gY4/4bJMa1/8+CSeK From: "brian m. carlson" To: Cc: Matthew DeVore , Eric Wong , Matthieu Moy Subject: [PATCH 07/14] t/lib-git-svn: make hash size independent Date: Fri, 19 Jun 2020 22:39:40 +0000 Message-Id: <20200619223947.947067-8-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.27.0.278.ge193c7cf3a9 In-Reply-To: <20200619223947.947067-1-sandals@crustytoothpaste.net> References: <20200619223947.947067-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 The record size used in the git svn storage is four bytes plus the length of the binary hash. Pass the hash length into our Perl invocation and use it to compute the size of the records. Signed-off-by: brian m. carlson --- t/lib-git-svn.sh | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh index 7d248e6588..4780b45337 100644 --- a/t/lib-git-svn.sh +++ b/t/lib-git-svn.sh @@ -78,29 +78,30 @@ maybe_start_httpd () { } convert_to_rev_db () { - perl -w -- - "$@" <<\EOF -use strict; + perl -w -e "use strict; my \$oidlen = $(test_oid rawsz);" -e ' @ARGV == 2 or die "usage: convert_to_rev_db "; -open my $wr, '+>', $ARGV[1] or die "$!: couldn't open: $ARGV[1]"; -open my $rd, '<', $ARGV[0] or die "$!: couldn't open: $ARGV[0]"; +my $record_size = $oidlen + 4; +my $hexlen = $oidlen * 2; +open my $wr, "+>", $ARGV[1] or die "$!: couldn'\''t open: $ARGV[1]"; +open my $rd, "<", $ARGV[0] or die "$!: couldn'\''t open: $ARGV[0]"; my $size = (stat($rd))[7]; -($size % 24) == 0 or die "Inconsistent size: $size"; -while (sysread($rd, my $buf, 24) == 24) { - my ($r, $c) = unpack('NH40', $buf); - my $offset = $r * 41; +($size % $record_size) == 0 or die "Inconsistent size: $size"; +while (sysread($rd, my $buf, $record_size) == $record_size) { + my ($r, $c) = unpack("NH$hexlen", $buf); + my $offset = $r * ($hexlen + 1); seek $wr, 0, 2 or die $!; my $pos = tell $wr; if ($pos < $offset) { - for (1 .. (($offset - $pos) / 41)) { - print $wr (('0' x 40),"\n") or die $!; + for (1 .. (($offset - $pos) / ($hexlen + 1))) { + print $wr (('0' x $hexlen),"\n") or die $!; } } seek $wr, $offset, 0 or die $!; print $wr $c,"\n" or die $!; } close $wr or die $!; -close $rd or die $!; -EOF +close $rd or die $!;' \ + -- "$@" } require_svnserve () { From patchwork Fri Jun 19 22:39:41 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: 11615297 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 09D3F913 for ; Fri, 19 Jun 2020 22:52:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E5389223C6 for ; Fri, 19 Jun 2020 22:52:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (3072-bit key) header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.b="tlHgBRTt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729830AbgFSWwK (ORCPT ); Fri, 19 Jun 2020 18:52:10 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:39848 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729746AbgFSWwH (ORCPT ); Fri, 19 Jun 2020 18:52:07 -0400 Received: from camp.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:7d4e:cde:7c41:71c2]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id F067960A69; Fri, 19 Jun 2020 22:51:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1592607095; bh=ackgtsKGAbZAljcOkN+4IxjqUnwTxVQfXHXDz875pzU=; 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=tlHgBRTtQ/I7hDOS1gL3xO75HXpnC+uWjN4khBY/HmklFbQ0ai2NsYMuZHVV3Bla6 +ZMHFQM25hN5MmBoW7NJLJzYYUHRcwCFUkC6SaGDzrmsX7TKfxBiVF+EVeAIWMiJJz PK8MFh1kyybVVESrGFeOhCbPdgh9wheQ3aP23I5Enkfymw/8CFL0N92+hR4Tp+rSTJ TycFADZ6uOa/aJolGcfJUArDZqnEsP+qJkBDJWsaUnUUMvLDknqBMh9bOyPBbcoO2y xr5uAJ6zkGy897n7t7WtPT0nCuBZ6okbP5yrMllYCknJZffQ3MK4ksrax59EUst/EU Oi27gneI2U33ULXqKQd1bs5ZaF66ZNvYrCChTiUxXewLGbN43gJbJHrATgaPiY3ynv KslnIjMMy+eX1iqNDnrib8iTNeY8O3tE/5W+suaGfejWmeFNgHRycaNnLz9lJvdaDW DLENAVrTUxdzAeP84J5ueSZHp3xMLSeClI18k0n8LFvnkFJLIOH From: "brian m. carlson" To: Cc: Matthew DeVore , Eric Wong , Matthieu Moy Subject: [PATCH 08/14] perl: create and switch variables for hash constants Date: Fri, 19 Jun 2020 22:39:41 +0000 Message-Id: <20200619223947.947067-9-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.27.0.278.ge193c7cf3a9 In-Reply-To: <20200619223947.947067-1-sandals@crustytoothpaste.net> References: <20200619223947.947067-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 git-svn has several variables for SHA-1 constants, including short hash values and full length hash values. Since these are no longer SHA-1 specific, let's start them with "oid" instead of "sha1". Add a constant, oid_length, which is the length of the hash algorithm in use in hex. We use the hex version because overwhelmingly that's what's used by git-svn. We don't currently set oid_length based on the repository algorithm, but we will in a future commit. Signed-off-by: brian m. carlson --- git-svn.perl | 14 ++++++++------ perl/Git/SVN.pm | 10 +++++----- perl/Git/SVN/Editor.pm | 2 +- perl/Git/SVN/Log.pm | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/git-svn.perl b/git-svn.perl index 4aa208ff5f..7c735cebd3 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -5,7 +5,8 @@ use warnings; use strict; use vars qw/ $AUTHOR $VERSION - $sha1 $sha1_short $_revision $_repository + $oid $oid_short $oid_length + $_revision $_repository $_q $_authors $_authors_prog %users/; $AUTHOR = 'Eric Wong '; $VERSION = '@@GIT_VERSION@@'; @@ -103,8 +104,9 @@ sub _req_svn { } } -$sha1 = qr/[a-f\d]{40}/; -$sha1_short = qr/[a-f\d]{4,40}/; +$oid = qr/(?:[a-f\d]{40}(?:[a-f\d]{24})?)/; +$oid_short = qr/[a-f\d]{4,64}/; +$oid_length = 40; my ($_stdin, $_help, $_edit, $_message, $_file, $_branch_dest, $_template, $_shared, @@ -582,7 +584,7 @@ sub cmd_set_tree { print "Reading from stdin...\n"; @commits = (); while () { - if (/\b($sha1_short)\b/o) { + if (/\b($oid_short)\b/o) { unshift @commits, $1; } } @@ -1831,7 +1833,7 @@ sub get_tree_from_treeish { if ($type eq 'commit') { $expected = (grep /^tree /, command(qw/cat-file commit/, $treeish))[0]; - ($expected) = ($expected =~ /^tree ($sha1)$/o); + ($expected) = ($expected =~ /^tree ($oid)$/o); die "Unable to get tree from $treeish\n" unless $expected; } elsif ($type eq 'tree') { $expected = $treeish; @@ -2036,7 +2038,7 @@ sub working_head_info { my $hash; my %max; while (<$fh>) { - if ( m{^commit ($::sha1)$} ) { + if ( m{^commit ($::oid)$} ) { unshift @$refs, $hash if $hash and $refs; $hash = $1; next; diff --git a/perl/Git/SVN.pm b/perl/Git/SVN.pm index 4b28b87784..fcf1e3bb5e 100644 --- a/perl/Git/SVN.pm +++ b/perl/Git/SVN.pm @@ -874,7 +874,7 @@ sub assert_index_clean { command_noisy('read-tree', $treeish) unless -e $self->{index}; my $x = command_oneline('write-tree'); my ($y) = (command(qw/cat-file commit/, $treeish) =~ - /^tree ($::sha1)/mo); + /^tree ($::oid)/mo); return if $y eq $x; warn "Index mismatch: $y != $x\nrereading $treeish\n"; @@ -1020,7 +1020,7 @@ sub do_git_commit { $tree = $self->tmp_index_do(sub { command_oneline('write-tree') }); } - die "Tree is not a valid sha1: $tree\n" if $tree !~ /^$::sha1$/o; + die "Tree is not a valid oid $tree\n" if $tree !~ /^$::oid$/o; my @exec = ('git', 'commit-tree', $tree); foreach ($self->get_commit_parents($log_entry)) { @@ -1048,8 +1048,8 @@ sub do_git_commit { close $out_fh or croak $!; waitpid $pid, 0; croak $? if $?; - if ($commit !~ /^$::sha1$/o) { - die "Failed to commit, invalid sha1: $commit\n"; + if ($commit !~ /^$::oid$/o) { + die "Failed to commit, invalid oid: $commit\n"; } $self->rev_map_set($log_entry->{revision}, $commit, 1); @@ -2150,7 +2150,7 @@ sub rebuild { my $svn_uuid = $self->rewrite_uuid || $self->ra_uuid; my $c; while (<$log>) { - if ( m{^commit ($::sha1)$} ) { + if ( m{^commit ($::oid)$} ) { $c = $1; next; } diff --git a/perl/Git/SVN/Editor.pm b/perl/Git/SVN/Editor.pm index 0df16ed726..70b6d78cd9 100644 --- a/perl/Git/SVN/Editor.pm +++ b/perl/Git/SVN/Editor.pm @@ -63,7 +63,7 @@ sub generate_diff { my @mods; while (defined($_ = get_record($diff_fh, "\0"))) { if ($state eq 'meta' && /^:(\d{6})\s(\d{6})\s - ($::sha1)\s($::sha1)\s + ($::oid)\s($::oid)\s ([MTCRAD])\d*$/xo) { push @mods, { mode_a => $1, mode_b => $2, sha1_a => $3, sha1_b => $4, diff --git a/perl/Git/SVN/Log.pm b/perl/Git/SVN/Log.pm index 664105357c..3858fcf27d 100644 --- a/perl/Git/SVN/Log.pm +++ b/perl/Git/SVN/Log.pm @@ -285,7 +285,7 @@ sub cmd_show_log { my (@k, $c, $d, $stat); my $esc_color = qr/(?:\033\[(?:(?:\d+;)*\d*)?m)*/; while (<$log>) { - if (/^${esc_color}commit (?:- )?($::sha1_short)/o) { + if (/^${esc_color}commit (?:- )?($::oid_short)/o) { my $cmt = $1; if ($c && cmt_showable($c) && $c->{r} != $r_last) { $r_last = $c->{r}; From patchwork Fri Jun 19 22:39:42 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: 11615275 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 92B40913 for ; Fri, 19 Jun 2020 22:51:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 71F02223C6 for ; Fri, 19 Jun 2020 22:51:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (3072-bit key) header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.b="0/w5NRcu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729765AbgFSWvj (ORCPT ); Fri, 19 Jun 2020 18:51:39 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:39744 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726900AbgFSWvh (ORCPT ); Fri, 19 Jun 2020 18:51:37 -0400 Received: from camp.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:7d4e:cde:7c41:71c2]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 86FC160A6A; Fri, 19 Jun 2020 22:51:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1592607095; bh=rGGLBfcx22IVYnzje3das6IhdM10H333AO2lxvPa2RQ=; 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=0/w5NRcuSizaqPK8pOZY9UYYVK98Kby5LLl50Zv0420WMaQwOufO4+XBKLjaqgLZl dtZ/gzmAf3xUmHnVXSV4XzCf2NY4guAc4T0lc5c1kGYA9TwLTdQDM+j3L6s7cBL1eJ 0tti0PLYn1tqHLV2ATHULB3xiqKeH6aGO3CVIzgNpZbbs0gPf6fkL5N4ut5y7Nmhpn ErlzCcVa9PsQczEtJMySxPU4TQPF4E/Vn3ppcL5vm2SqquU49UmMnezLSipbbwQqS9 /6h4PkrUtTwZBWvlodE2qNzUkIDu9twT2icQX5T11uYRXKmx9BMoHTsg8PgtGCoPle YUnXT7BcCIwMmLh+gkuJGBjOLHjnk3KMuLIVGHbG2HSVrAq/tZ2vtC32J2f2hSS+H4 UBVxXMK14iqgD2DEXq/yy7PcszHPariMmDUqV8ClYqtxlMseLa2rDm4DCtgqCGnNk+ erVP1H3RMTWIPFnBB5S/v64pw6ygpBB05s83tLmpnYf8jI24Ypm From: "brian m. carlson" To: Cc: Matthew DeVore , Eric Wong , Matthieu Moy Subject: [PATCH 09/14] perl: make Git::IndexInfo work with SHA-256 Date: Fri, 19 Jun 2020 22:39:42 +0000 Message-Id: <20200619223947.947067-10-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.27.0.278.ge193c7cf3a9 In-Reply-To: <20200619223947.947067-1-sandals@crustytoothpaste.net> References: <20200619223947.947067-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 Most of the Git modules, git-svn excepted, don't know anything about the hash algorithm and mostly work. However, when we're printing an all-zero object ID in Git::IndexInfo, we need to know the hash length. Since we don't want to change the API to have that information passed in, let's query the config to find the hash algorithm and compute the right value. Signed-off-by: brian m. carlson --- perl/Git/IndexInfo.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/perl/Git/IndexInfo.pm b/perl/Git/IndexInfo.pm index a43108c985..2a7b4908f3 100644 --- a/perl/Git/IndexInfo.pm +++ b/perl/Git/IndexInfo.pm @@ -5,13 +5,15 @@ package Git::IndexInfo; sub new { my ($class) = @_; + my $hash_algo = Git::config('extensions.objectformat') || 'sha1'; my ($gui, $ctx) = command_input_pipe(qw/update-index -z --index-info/); - bless { gui => $gui, ctx => $ctx, nr => 0}, $class; + bless { gui => $gui, ctx => $ctx, nr => 0, hash_algo => $hash_algo}, $class; } sub remove { my ($self, $path) = @_; - if (print { $self->{gui} } '0 ', 0 x 40, "\t", $path, "\0") { + my $length = $self->{hash_algo} eq 'sha256' ? 64 : 40; + if (print { $self->{gui} } '0 ', 0 x $length, "\t", $path, "\0") { return ++$self->{nr}; } undef; From patchwork Fri Jun 19 22:39:43 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: 11615295 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 04D08913 for ; Fri, 19 Jun 2020 22:52:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D5347223BF for ; Fri, 19 Jun 2020 22:52:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (3072-bit key) header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.b="gIZiNW8J" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729832AbgFSWwK (ORCPT ); Fri, 19 Jun 2020 18:52:10 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:39854 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729822AbgFSWwI (ORCPT ); Fri, 19 Jun 2020 18:52:08 -0400 Received: from camp.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:7d4e:cde:7c41:71c2]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 1EB1F60A6C; Fri, 19 Jun 2020 22:51:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1592607096; bh=JfIMLisphWeO+W56KfkiYhmAoUcNsACETXaUAtTQUiQ=; 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=gIZiNW8J9YFPEQ/IRjJePQqI9h5tqdTTw6W4pj9uiFDF1VNgXZKcnBG0dAKEx9cMW woroZmWh0nnoMAhBnFYbjVPzP7a1mNMggvXJ8/BUJCg6NBuLJl+YOfjrhaJLlliybI Gw/2dGMXqOpO1tMTBlD+3cmDUWzs1DyqilUsgcN75Lb4HT7MzCWnb/8N1aPZ5L47rF GBUc7zOjklMLGEW8UtMidO5G+ZOPCXOn/aKLfJPbr7MNqngmtfMV7ZfKfOeTfWIMH1 9CNWimRGdCG5D3cKN+A6miH5i3MhD8XWudyE7Zg0BjZyBS8exN6+5f3T0rNYasV4U3 7ct761SxO7i4gFLhUvhzjweEwDxVLhA6UYkL+98MJqMlziQ9l/0BmC31Ycd7Oc1+in ihwAkMRBfPLKR6hqq77YcRTdF8jYKhvuyp+6hlTKQXmyvjOanY/crNhrW4mxhIr2cL Jhhgr5f+nneDiHOq+iRJxTec1Qc2iI3wh0o0vHqJhjzm47uu6un From: "brian m. carlson" To: Cc: Matthew DeVore , Eric Wong , Matthieu Moy Subject: [PATCH 10/14] perl: make SVN code hash independent Date: Fri, 19 Jun 2020 22:39:43 +0000 Message-Id: <20200619223947.947067-11-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.27.0.278.ge193c7cf3a9 In-Reply-To: <20200619223947.947067-1-sandals@crustytoothpaste.net> References: <20200619223947.947067-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 There are several places throughout git-svn that use various hard-coded constants. For matching object IDs, use the $oid variable. Compute the record size we use for our revision storage based on the object ID. When parsing the revision map format, use a wildcard in the pack format since we know that the data we're parsing is always exactly the record size. This lets us continue to use a constant for the pack format. Finally, update several comments to reflect the fact that an object ID may be of one of multiple sizes. Signed-off-by: brian m. carlson --- git-svn.perl | 4 +-- perl/Git/SVN.pm | 73 +++++++++++++++++++++-------------------- perl/Git/SVN/Editor.pm | 6 ++-- perl/Git/SVN/Fetcher.pm | 6 ++-- perl/Git/SVN/Ra.pm | 4 +-- 5 files changed, 48 insertions(+), 45 deletions(-) diff --git a/git-svn.perl b/git-svn.perl index 7c735cebd3..00276c051b 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2008,10 +2008,10 @@ sub cmt_sha2rev_batch { print $out $sha, "\n"; while (my $line = <$in>) { - if ($first && $line =~ /^[[:xdigit:]]{40}\smissing$/) { + if ($first && $line =~ /^$::oid\smissing$/) { last; } elsif ($first && - $line =~ /^[[:xdigit:]]{40}\scommit\s(\d+)$/) { + $line =~ /^$::oid\scommit\s(\d+)$/) { $first = 0; $size = $1; next; diff --git a/perl/Git/SVN.pm b/perl/Git/SVN.pm index fcf1e3bb5e..d1c352f92b 100644 --- a/perl/Git/SVN.pm +++ b/perl/Git/SVN.pm @@ -2,7 +2,7 @@ package Git::SVN; use strict; use warnings; use Fcntl qw/:DEFAULT :seek/; -use constant rev_map_fmt => 'NH40'; +use constant rev_map_fmt => 'NH*'; use vars qw/$_no_metadata $_repack $_repack_flags $_use_svm_props $_head $_use_svnsync_props $no_reuse_existing @@ -2087,10 +2087,10 @@ sub rebuild_from_rev_db { open my $fh, '<', $path or croak "open: $!"; binmode $fh or croak "binmode: $!"; while (<$fh>) { - length($_) == 41 or croak "inconsistent size in ($_) != 41"; + length($_) == $::oid_length + 1 or croak "inconsistent size in ($_)"; chomp($_); ++$r; - next if $_ eq ('0' x 40); + next if $_ eq ('0' x $::oid_length); $self->rev_map_set($r, $_); print "r$r = $_\n"; } @@ -2196,9 +2196,9 @@ sub rebuild { # (mainly tags) # # The format is this: -# - 24 bytes for every record, +# - 24 or 36 bytes for every record, # * 4 bytes for the integer representing an SVN revision number -# * 20 bytes representing the sha1 of a git commit +# * 20 or 32 bytes representing the oid of a git commit # - No empty padding records like the old format # (except the last record, which can be overwritten) # - new records are written append-only since SVN revision numbers @@ -2207,7 +2207,7 @@ sub rebuild { # - Piping the file to xxd -c24 is a good way of dumping it for # viewing or editing (piped back through xxd -r), should the need # ever arise. -# - The last record can be padding revision with an all-zero sha1 +# - The last record can be padding revision with an all-zero oid # This is used to optimize fetch performance when using multiple # "fetch" directives in .git/config # @@ -2215,38 +2215,39 @@ sub rebuild { sub _rev_map_set { my ($fh, $rev, $commit) = @_; + my $record_size = ($::oid_length / 2) + 4; binmode $fh or croak "binmode: $!"; my $size = (stat($fh))[7]; - ($size % 24) == 0 or croak "inconsistent size: $size"; + ($size % $record_size) == 0 or croak "inconsistent size: $size"; my $wr_offset = 0; if ($size > 0) { - sysseek($fh, -24, SEEK_END) or croak "seek: $!"; - my $read = sysread($fh, my $buf, 24) or croak "read: $!"; - $read == 24 or croak "read only $read bytes (!= 24)"; + sysseek($fh, -$record_size, SEEK_END) or croak "seek: $!"; + my $read = sysread($fh, my $buf, $record_size) or croak "read: $!"; + $read == $record_size or croak "read only $read bytes (!= $record_size)"; my ($last_rev, $last_commit) = unpack(rev_map_fmt, $buf); - if ($last_commit eq ('0' x40)) { - if ($size >= 48) { - sysseek($fh, -48, SEEK_END) or croak "seek: $!"; - $read = sysread($fh, $buf, 24) or + if ($last_commit eq ('0' x $::oid_length)) { + if ($size >= ($record_size * 2)) { + sysseek($fh, -($record_size * 2), SEEK_END) or croak "seek: $!"; + $read = sysread($fh, $buf, $record_size) or croak "read: $!"; - $read == 24 or - croak "read only $read bytes (!= 24)"; + $read == $record_size or + croak "read only $read bytes (!= $record_size)"; ($last_rev, $last_commit) = unpack(rev_map_fmt, $buf); - if ($last_commit eq ('0' x40)) { + if ($last_commit eq ('0' x $::oid_length)) { croak "inconsistent .rev_map\n"; } } if ($last_rev >= $rev) { croak "last_rev is higher!: $last_rev >= $rev"; } - $wr_offset = -24; + $wr_offset = -$record_size; } } sysseek($fh, $wr_offset, SEEK_END) or croak "seek: $!"; - syswrite($fh, pack(rev_map_fmt, $rev, $commit), 24) == 24 or + syswrite($fh, pack(rev_map_fmt, $rev, $commit), $record_size) == $record_size or croak "write: $!"; } @@ -2271,7 +2272,7 @@ sub mkfile { sub rev_map_set { my ($self, $rev, $commit, $update_ref, $uuid) = @_; defined $commit or die "missing arg3\n"; - length $commit == 40 or die "arg3 must be a full SHA1 hexsum\n"; + $commit =~ /^$::oid$/ or die "arg3 must be a full hex object ID\n"; my $db = $self->map_path($uuid); my $db_lock = "$db.lock"; my $sigmask; @@ -2344,29 +2345,30 @@ sub rev_map_max { sub rev_map_max_norebuild { my ($self, $want_commit) = @_; + my $record_size = ($::oid_length / 2) + 4; my $map_path = $self->map_path; stat $map_path or return $want_commit ? (0, undef) : 0; sysopen(my $fh, $map_path, O_RDONLY) or croak "open: $!"; binmode $fh or croak "binmode: $!"; my $size = (stat($fh))[7]; - ($size % 24) == 0 or croak "inconsistent size: $size"; + ($size % $record_size) == 0 or croak "inconsistent size: $size"; if ($size == 0) { close $fh or croak "close: $!"; return $want_commit ? (0, undef) : 0; } - sysseek($fh, -24, SEEK_END) or croak "seek: $!"; - sysread($fh, my $buf, 24) == 24 or croak "read: $!"; + sysseek($fh, -$record_size, SEEK_END) or croak "seek: $!"; + sysread($fh, my $buf, $record_size) == $record_size or croak "read: $!"; my ($r, $c) = unpack(rev_map_fmt, $buf); - if ($want_commit && $c eq ('0' x40)) { - if ($size < 48) { + if ($want_commit && $c eq ('0' x $::oid_length)) { + if ($size < $record_size * 2) { return $want_commit ? (0, undef) : 0; } - sysseek($fh, -48, SEEK_END) or croak "seek: $!"; - sysread($fh, $buf, 24) == 24 or croak "read: $!"; + sysseek($fh, -($record_size * 2), SEEK_END) or croak "seek: $!"; + sysread($fh, $buf, $record_size) == $record_size or croak "read: $!"; ($r, $c) = unpack(rev_map_fmt, $buf); - if ($c eq ('0'x40)) { + if ($c eq ('0' x $::oid_length)) { croak "Penultimate record is all-zeroes in $map_path"; } } @@ -2387,30 +2389,31 @@ sub rev_map_get { sub _rev_map_get { my ($fh, $rev) = @_; + my $record_size = ($::oid_length / 2) + 4; binmode $fh or croak "binmode: $!"; my $size = (stat($fh))[7]; - ($size % 24) == 0 or croak "inconsistent size: $size"; + ($size % $record_size) == 0 or croak "inconsistent size: $size"; if ($size == 0) { return undef; } - my ($l, $u) = (0, $size - 24); + my ($l, $u) = (0, $size - $record_size); my ($r, $c, $buf); while ($l <= $u) { - my $i = int(($l/24 + $u/24) / 2) * 24; + my $i = int(($l/$record_size + $u/$record_size) / 2) * $record_size; sysseek($fh, $i, SEEK_SET) or croak "seek: $!"; - sysread($fh, my $buf, 24) == 24 or croak "read: $!"; + sysread($fh, my $buf, $record_size) == $record_size or croak "read: $!"; my ($r, $c) = unpack(rev_map_fmt, $buf); if ($r < $rev) { - $l = $i + 24; + $l = $i + $record_size; } elsif ($r > $rev) { - $u = $i - 24; + $u = $i - $record_size; } else { # $r == $rev - return $c eq ('0' x 40) ? undef : $c; + return $c eq ('0' x $::oid_length) ? undef : $c; } } undef; diff --git a/perl/Git/SVN/Editor.pm b/perl/Git/SVN/Editor.pm index 70b6d78cd9..c961444d4c 100644 --- a/perl/Git/SVN/Editor.pm +++ b/perl/Git/SVN/Editor.pm @@ -400,12 +400,12 @@ sub T { ($m->{mode_b} !~ /^120/ && $m->{mode_a} =~ /^120/)) { $self->D({ mode_a => $m->{mode_a}, mode_b => '000000', - sha1_a => $m->{sha1_a}, sha1_b => '0' x 40, + sha1_a => $m->{sha1_a}, sha1_b => '0' x $::oid_length, chg => 'D', file_b => $m->{file_b} }, $deletions); $self->A({ mode_a => '000000', mode_b => $m->{mode_b}, - sha1_a => '0' x 40, sha1_b => $m->{sha1_b}, + sha1_a => '0' x $::oid_length, sha1_b => $m->{sha1_b}, chg => 'A', file_b => $m->{file_b} }, $deletions); return; @@ -434,7 +434,7 @@ ($$$$) $self->change_file_prop($fbat,'svn:special',undef); } my $blob = $m->{"sha1_$which"}; - return ($fh,) if ($blob =~ /^0{40}$/); + return ($fh,) if ($blob =~ /^0+$/); my $size = $::_repository->cat_blob($blob, $fh); croak "Failed to read object $blob" if ($size < 0); $fh->flush == 0 or croak $!; diff --git a/perl/Git/SVN/Fetcher.pm b/perl/Git/SVN/Fetcher.pm index 64e900a0e9..729e5337df 100644 --- a/perl/Git/SVN/Fetcher.pm +++ b/perl/Git/SVN/Fetcher.pm @@ -173,7 +173,7 @@ sub delete_entry { # remove entire directories. my ($tree) = (command('ls-tree', '-z', $self->{c}, "./$gpath") - =~ /\A040000 tree ([a-f\d]{40})\t\Q$gpath\E\0/); + =~ /\A040000 tree ($::oid)\t\Q$gpath\E\0/); if ($tree) { my ($ls, $ctx) = command_output_pipe(qw/ls-tree -r --name-only -z/, @@ -203,7 +203,7 @@ sub open_file { my $gpath = $self->git_path($path); ($mode, $blob) = (command('ls-tree', '-z', $self->{c}, "./$gpath") - =~ /\A(\d{6}) blob ([a-f\d]{40})\t\Q$gpath\E\0/); + =~ /\A(\d{6}) blob ($::oid)\t\Q$gpath\E\0/); unless (defined $mode && defined $blob) { die "$path was not found in commit $self->{c} (r$rev)\n"; } @@ -413,7 +413,7 @@ sub close_file { $hash = $::_repository->hash_and_insert_object( Git::temp_path($fh)); - $hash =~ /^[a-f\d]{40}$/ or die "not a sha1: $hash\n"; + $hash =~ /^$::oid$/ or die "not an object ID: $hash\n"; Git::temp_release($fb->{base}, 1); Git::temp_release($fh, 1); diff --git a/perl/Git/SVN/Ra.pm b/perl/Git/SVN/Ra.pm index 56ad9870bc..2cfe055a9a 100644 --- a/perl/Git/SVN/Ra.pm +++ b/perl/Git/SVN/Ra.pm @@ -486,11 +486,11 @@ sub gs_fetch_loop_common { $reload_ra->() if $ra_invalid; } # pre-fill the .rev_db since it'll eventually get filled in - # with '0' x40 if something new gets committed + # with '0' x $oid_length if something new gets committed foreach my $gs (@$gsv) { next if $gs->rev_map_max >= $max; next if defined $gs->rev_map_get($max); - $gs->rev_map_set($max, 0 x40); + $gs->rev_map_set($max, 0 x $::oid_length); } foreach my $g (@$globs) { my $k = "svn-remote.$g->{remote}.$g->{t}-maxRev"; From patchwork Fri Jun 19 22:39:44 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: 11615281 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 6C4D0913 for ; Fri, 19 Jun 2020 22:51:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 48B37223C6 for ; Fri, 19 Jun 2020 22:51:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (3072-bit key) header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.b="WnTyGrhh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729777AbgFSWvm (ORCPT ); Fri, 19 Jun 2020 18:51:42 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:39744 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729714AbgFSWvj (ORCPT ); Fri, 19 Jun 2020 18:51:39 -0400 Received: from camp.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:7d4e:cde:7c41:71c2]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id A7D8360A6F; Fri, 19 Jun 2020 22:51:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1592607097; bh=YpC9mCELaC60Sj+3WlcVzyOVoGz2YB+ad2YkjK6/c90=; 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=WnTyGrhhWRcOuSwxa6YvWPQuxkAsHmvrGO5TK/WJmBr9pHLer48WyJERQtT23bEtN 50XPllolYCqxiUp3Ay6Ik4z3FREKWbx6CObKatbVaWV3h6JdWQRhga4cnvqsMxf0ap W962fB29nbi/u+CgCeeGmxUdZWvecNI+RjO+Yka0vpVspEw0tGqPIyS0i7iqA5gD7J 6sy+k0kVrVz8HB9DTqD0T8pvLu2P6c1qtBjiKY9vZZ8tvn/5Yt5QYR++BKkEy5oqHQ CrTJEb+om9Z7aXLBtz5BWfNoRogd8a+Gks8ItLCULUFP32mUpWx7zU7E1gQb8zZ5aL mUaJb6B2btLxPeHDiLTC6mKQddSeu3IqdMIgHRAPhuvCyftCM4thMIW2kJajFFGNwD 11o+8NCLjb+Wy0O8Vve8nGoXtUI9a9syjMs5VIXLuXxLcRL8D09Cy2WIeYcHYiRtFI iOPAoscYfaJi2vdpQTYvBeRUpboJCLNZ9GpnXSDo2mgmj/GM+5S From: "brian m. carlson" To: Cc: Matthew DeVore , Eric Wong , Matthieu Moy Subject: [PATCH 11/14] git-svn: set the OID length based on hash algorithm Date: Fri, 19 Jun 2020 22:39:44 +0000 Message-Id: <20200619223947.947067-12-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.27.0.278.ge193c7cf3a9 In-Reply-To: <20200619223947.947067-1-sandals@crustytoothpaste.net> References: <20200619223947.947067-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 When reading the configuration or when creating a new repository, load the extensions.objectFormat value and set the object ID length to 64 if it's "sha256". Note that we use the hex length in git-svn because most of our processing is done on hex values, not binary ones. Signed-off-by: brian m. carlson --- git-svn.perl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/git-svn.perl b/git-svn.perl index 00276c051b..58f5a7ac8f 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -500,6 +500,7 @@ sub do_git_init_db { command_noisy('config', "$pfx.preserve-empty-dirs", 'true'); command_noisy('config', "$pfx.placeholder-filename", $$fname); } + load_object_format(); } sub init_subdir { @@ -1977,9 +1978,15 @@ sub read_git_config { } } } + load_object_format(); delete @$opts{@config_only} if @config_only; } +sub load_object_format { + chomp(my $hash = `git config --get extensions.objectformat`); + $::oid_length = 64 if $hash eq 'sha256'; +} + sub extract_metadata { my $id = shift or return (undef, undef, undef); my ($url, $rev, $uuid) = ($id =~ /^\s*git-svn-id:\s+(.*)\@(\d+) From patchwork Fri Jun 19 22:39:45 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: 11615285 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 3B40F13B1 for ; Fri, 19 Jun 2020 22:51:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1F418223C6 for ; Fri, 19 Jun 2020 22:51:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (3072-bit key) header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.b="ZCODg56D" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729789AbgFSWvo (ORCPT ); Fri, 19 Jun 2020 18:51:44 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:39802 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729746AbgFSWvj (ORCPT ); Fri, 19 Jun 2020 18:51:39 -0400 Received: from camp.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:7d4e:cde:7c41:71c2]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 3E1F660A72; Fri, 19 Jun 2020 22:51:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1592607097; bh=/RCWfAMlaGU8Y+6sjRJ8oDEKHR0VpV2hOcyN+/qexsY=; 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=ZCODg56DschXDMNWY5phuKvWxHS1isqnnnFTIzXnwIMxSPER7Xr6X19ijc6KJPC7u Sc4RQ68axAChEJCBuE2byblEKP/FkbXIrf/+p8LvaSXh/doSwKqq8FkHdU3OPqQYlx 23oLZwUMlkMj8kcIArd19NsMqeqf/zkIoEz62I3hytdXz6aC1OJgE/XKKZvgra3o00 urOZHLG4HGjHRA8tOhV33geuH6wVScZUAx+pBHKfe07cpXH7PafQGoWvi+ltGI3Y3e 2z7eywdb/u8ogq7KwE1O8lC/BUDm7gK0skqVSCWy8V96x1tZdo3RPr7PD98bMFrL6t Ei36kpCCBCng3BMDFsgWXW7UzNZUvII+XLdRru8dDjraO8DsysSe/VGNVi4z+Knd1x C4fasAnkQnSlwPraQhdf2X/znVAY2CPsam4RiS5R8vbAEc+rnbPFyD9HKNOjhv1i8B iiR7HKYir/oHBeFDJj93iLfpJFSM2uJxsAQwHPf1BC79b9tFzPq From: "brian m. carlson" To: Cc: Matthew DeVore , Eric Wong , Matthieu Moy Subject: [PATCH 12/14] git-cvsserver: port to SHA-256 Date: Fri, 19 Jun 2020 22:39:45 +0000 Message-Id: <20200619223947.947067-13-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.27.0.278.ge193c7cf3a9 In-Reply-To: <20200619223947.947067-1-sandals@crustytoothpaste.net> References: <20200619223947.947067-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 The code of git-cvsserver currently has several hard-coded 20 and 40 constants that are the length of SHA-1. When parsing the configuration file, read the extensions.objectformat configuration setting as well as CVS-related ones and adjust the hash sizes accordingly. Use these computed values in all the places we match object IDs. Signed-off-by: brian m. carlson --- git-cvsserver.perl | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/git-cvsserver.perl b/git-cvsserver.perl index ae1044273d..f6f3fc192c 100755 --- a/git-cvsserver.perl +++ b/git-cvsserver.perl @@ -365,7 +365,7 @@ sub req_Root } foreach my $line ( @gitvars ) { - next unless ( $line =~ /^(gitcvs)\.(?:(ext|pserver)\.)?([\w-]+)=(.*)$/ ); + next unless ( $line =~ /^(gitcvs|extensions)\.(?:(ext|pserver)\.)?([\w-]+)=(.*)$/ ); unless ($2) { $cfg->{$1}{$3} = $4; } else { @@ -392,6 +392,9 @@ sub req_Root $log->nofile(); } + $state->{rawsz} = ($cfg->{'extensions'}{'objectformat'} || 'sha1') eq 'sha256' ? 32 : 20; + $state->{hexsz} = $state->{rawsz} * 2; + return 1; } @@ -1581,7 +1584,7 @@ sub req_ci $parenthash = safe_pipe_capture('git', 'show-ref', '-s', $branchRef); chomp $parenthash; - if ($parenthash !~ /^[0-9a-f]{40}$/) + if ($parenthash !~ /^[0-9a-f]{$state->{hexsz}}$/) { if ( defined($stickyInfo) && defined($stickyInfo->{tag}) ) { @@ -1708,7 +1711,7 @@ sub req_ci chomp($commithash); $log->info("Commit hash : $commithash"); - unless ( $commithash =~ /[a-zA-Z0-9]{40}/ ) + unless ( $commithash =~ /[a-zA-Z0-9]{$state->{hexsz}}/ ) { $log->warn("Commit failed (Invalid commit hash)"); print "error 1 Commit failed (unknown reason)\n"; @@ -2375,7 +2378,7 @@ sub req_annotate print "E ***************\n"; while ( ) { - if (m/^([a-zA-Z0-9]{40})\t\([^\)]*\)(.*)$/i) + if (m/^([a-zA-Z0-9]{$state->{hexsz}})\t\([^\)]*\)(.*)$/i) { my $commithash = $1; my $data = $2; @@ -2852,7 +2855,7 @@ sub transmitfile return; } - die "Need filehash" unless ( defined ( $filehash ) and $filehash =~ /^[a-zA-Z0-9]{40}$/ ); + die "Need filehash" unless ( defined ( $filehash ) and $filehash =~ /^[a-zA-Z0-9]{$state->{hexsz}}$/ ); my $type = safe_pipe_capture('git', 'cat-file', '-t', $filehash); chomp $type; @@ -3042,7 +3045,7 @@ sub ensureWorkTree my $ver = safe_pipe_capture('git', 'show-ref', '-s', "refs/heads/$state->{module}"); chomp $ver; - if ($ver !~ /^[0-9a-f]{40}$/) + if ($ver !~ /^[0-9a-f]{$state->{hexsz}}$/) { $log->warn("Error from git show-ref -s refs/head$state->{module}"); print "error 1 cannot find the current HEAD of module"; @@ -3281,7 +3284,7 @@ sub open_blob_or_die } elsif( $srcType eq "sha1" ) { - unless ( defined ( $name ) and $name =~ /^[a-zA-Z0-9]{40}$/ ) + unless ( defined ( $name ) and $name =~ /^[a-zA-Z0-9]{$state->{hexsz}}$/ ) { $log->warn("Need filehash"); die "Need filehash\n"; @@ -3817,7 +3820,7 @@ sub update chomp $commitsha1; my $commitinfo = ::safe_pipe_capture('git', 'cat-file', 'commit', $self->{module}); - unless ( $commitinfo =~ /tree\s+[a-zA-Z0-9]{40}/ ) + unless ( $commitinfo =~ /tree\s+[a-zA-Z0-9]{$state->{hexsz}}/ ) { die("Invalid module '$self->{module}'"); } @@ -3957,7 +3960,7 @@ sub update while ( ) { chomp; - unless ( /^:\d{6}\s+([0-7]{6})\s+[a-f0-9]{40}\s+([a-f0-9]{40})\s+(\w)$/o ) + unless ( /^:\d{6}\s+([0-7]{6})\s+[a-f0-9]{$state->{hexsz}}\s+([a-f0-9]{$state->{hexsz}})\s+(\w)$/o ) { die("Couldn't process git-diff-tree line : $_"); } @@ -4625,11 +4628,11 @@ sub getmeta $db_query->execute($filename, $intRev); $meta = $db_query->fetchrow_hashref; } - elsif ( $revision =~ /^2\.1\.1\.2000(\.[1-3][0-9][0-9]){20}$/ ) + elsif ( $revision =~ /^2\.1\.1\.2000(\.[1-3][0-9][0-9]){$state->{rawsz}}$/ ) { my ($commitHash)=($revision=~/^2\.1\.1\.2000(.*)$/); $commitHash=~s/\.([0-9]+)/sprintf("%02x",$1-100)/eg; - if($commitHash=~/^[0-9a-f]{40}$/) + if($commitHash=~/^[0-9a-f]{$state->{hexsz}}$/) { return $self->getMetaFromCommithash($filename,$commitHash); } @@ -4639,7 +4642,7 @@ sub getmeta $log->warning("failed get $revision with commithash=$commitHash"); undef $revision; } - elsif ( $revision =~ /^[0-9a-f]{40}$/ ) + elsif ( $revision =~ /^[0-9a-f]{$state->{hexsz}}$/ ) { # Try DB first. This is mostly only useful for req_annotate(), # which only calls this for stuff that should already be in @@ -4658,7 +4661,7 @@ sub getmeta if(! $meta) { my($revCommit)=$self->lookupCommitRef($revision); - if($revCommit=~/^[0-9a-f]{40}$/) + if($revCommit=~/^[0-9a-f]{$state->{hexsz}}$/) { return $self->getMetaFromCommithash($filename,$revCommit); } @@ -4672,7 +4675,7 @@ sub getmeta else { my($revCommit)=$self->lookupCommitRef($revision); - if($revCommit=~/^[0-9a-f]{40}$/) + if($revCommit=~/^[0-9a-f]{$state->{hexsz}}$/) { return $self->getMetaFromCommithash($filename,$revCommit); } @@ -4767,7 +4770,7 @@ sub getMetaFromCommithash my($fileHash) = ::safe_pipe_capture("git","rev-parse","$revCommit:$filename"); chomp $fileHash; - if(!($fileHash=~/^[0-9a-f]{40}$/)) + if(!($fileHash=~/^[0-9a-f]{$state->{hexsz}}$/)) { die "Invalid fileHash '$fileHash' looking up" ." '$revCommit:$filename'\n"; @@ -4863,7 +4866,7 @@ sub lookupCommitRef $commitHash = ::safe_pipe_capture("git","rev-parse","--verify","--quiet", $self->unescapeRefName($ref)); $commitHash=~s/\s*$//; - if(!($commitHash=~/^[0-9a-f]{40}$/)) + if(!($commitHash=~/^[0-9a-f]{$state->{hexsz}}$/)) { $commitHash=undef; } @@ -4909,7 +4912,7 @@ sub commitmessage my $commithash = shift; my $tablename = $self->tablename("commitmsgs"); - die("Need commithash") unless ( defined($commithash) and $commithash =~ /^[a-zA-Z0-9]{40}$/ ); + die("Need commithash") unless ( defined($commithash) and $commithash =~ /^[a-zA-Z0-9]{$state->{hexsz}}$/ ); my $db_query; $db_query = $self->{dbh}->prepare_cached("SELECT value FROM $tablename WHERE key=?",{},1); From patchwork Fri Jun 19 22:39:46 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: 11615279 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 136E214DD for ; Fri, 19 Jun 2020 22:51:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E4D24223C6 for ; Fri, 19 Jun 2020 22:51:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (3072-bit key) header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.b="JdC0ao4H" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729776AbgFSWvl (ORCPT ); Fri, 19 Jun 2020 18:51:41 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:39746 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729742AbgFSWvj (ORCPT ); Fri, 19 Jun 2020 18:51:39 -0400 Received: from camp.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:7d4e:cde:7c41:71c2]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id C840860A74; Fri, 19 Jun 2020 22:51:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1592607098; bh=Vt+S52KAiVY6VU5azzrjvNMZS8DsI5yczr9HIcJcdYY=; 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=JdC0ao4H/i/W+I9LYix6tWgAkfw+34GzVNQ7y6Y7pg7GhoKx8+eMSZ510RnTIFbfk mogLDSm2C560BEeNMwD4hC+vwCAVs5WJ2k7TgFSM1FjeFGdC9A6ZF4fmrlvi7vajSw sxjQEWnXWRypTG+0VNcQXRuToQq0MAGeNCuAEY+CEnGinLk600/FUyosN16nFWkh+L 06eqVRj2fgPeNEhlzrAnJDN1AKCNHqCjX0UEG348K6ENb4HaOX/Qvxl9CHXKMm9PMb 3fPN2Ash5WMHSalCb270ROyuCk+ZYuosVAiSjlbvJuuoTzLcsy7qKGrSvYiwW0kDRI QOkpZyvdNqyzHU2gMVJ8x3eBVk9G1Flz6I/YT/T8Jmx86jgzXMdQrVeJfWO3NbO4D4 dmL+YYTwV9nGYduKbWJ8zuFd0s65HihYsG9uxiLxQFUNulGVNlpel3M0xZr0N+6O8x tbxJvs+R6iRdJYxNTCChziIZjtXfGJ7SaAap8pqKPj51QSPSkMQ From: "brian m. carlson" To: Cc: Matthew DeVore , Eric Wong , Matthieu Moy Subject: [PATCH 13/14] git-cvsimport: port to SHA-256 Date: Fri, 19 Jun 2020 22:39:46 +0000 Message-Id: <20200619223947.947067-14-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.27.0.278.ge193c7cf3a9 In-Reply-To: <20200619223947.947067-1-sandals@crustytoothpaste.net> References: <20200619223947.947067-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 Instead of calling the function is_sha1, call it is_oid and update it to match either a SHA-1 or a SHA-256 hex object ID. Signed-off-by: brian m. carlson --- git-cvsimport.perl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/git-cvsimport.perl b/git-cvsimport.perl index 1057f389d3..7bf3c12d67 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -637,9 +637,9 @@ () return $pwd; } -sub is_sha1 { +sub is_oid { my $s = shift; - return $s =~ /^[a-f0-9]{40}$/; + return $s =~ /^[a-f0-9]{40}(?:[a-f0-9]{24})?$/; } sub get_headref ($) { @@ -810,7 +810,7 @@ () open(my $fh, '-|', qw(git write-tree)) or die "unable to open git write-tree: $!"; chomp(my $tree = <$fh>); - is_sha1($tree) + is_oid($tree) or die "Cannot get tree id ($tree): $!"; close($fh) or die "Error running git write-tree: $?\n"; @@ -896,7 +896,7 @@ sub commit { print "Committed patch $patchset ($branch $commit_date)\n" if $opt_v; chomp(my $cid = <$commit_read>); - is_sha1($cid) or die "Cannot get commit id ($cid): $!\n"; + is_oid($cid) or die "Cannot get commit id ($cid): $!\n"; print "Commit ID $cid\n" if $opt_v; close($commit_read); From patchwork Fri Jun 19 22:39:47 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: 11615283 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 F2C27913 for ; Fri, 19 Jun 2020 22:51:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D92DA223BE for ; Fri, 19 Jun 2020 22:51:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (3072-bit key) header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.b="hYb7ynGj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729785AbgFSWvo (ORCPT ); Fri, 19 Jun 2020 18:51:44 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:39818 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729759AbgFSWvk (ORCPT ); Fri, 19 Jun 2020 18:51:40 -0400 Received: from camp.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:7d4e:cde:7c41:71c2]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 5CC4F60A75; Fri, 19 Jun 2020 22:51:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1592607098; bh=WmegmhgXn6MZu3uuVPkEYPE6vUeT+x15UP1L4Sg+pnI=; 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=hYb7ynGjcpMrd43mt52iVLhM1/qzqR1qrxoL3tR508vcEdruHyxMN42ZVCuinVjW3 PTEWgMvF7VRwhu7W9zBI101wukaZtALMmJU2Xm1HNvrepgKWky5kRe7zuZI8rs0t20 kAmrGkz5wy9Krg3d/QAibPwjxSayc7PB4pu9/daM7BdwWH8coO5x163Jgkr0UOWjoO hMuAZKU/UEtVFaaPU1ieeSFP1YX3NHgeACTU6dENhvWkDmhrJY3TpVdzAC6QxlQEUs PPFbCQw3NEx5vj+etiRD6Dwh5UYhFoBxfnHKioZWxgoGprlx/pF94K+KTtey1C9f2J yEIkpRKsKhKPX2Fx4okJqv4iPJYFB+Amfvu4S/SaanqjzWd1tOQBIBMObdUSqHfX1D z8Fbk9r9DRSGl9kGzvfOSeENTDAlQvWbNdpWcuNDfSQDVo59XBINiMcTQ+a7ViLaeQ Qo/y2q7oLKJPi6u+tbEUMx7syLD8oq+iZODlP7I/+nZGPfFwZ2S From: "brian m. carlson" To: Cc: Matthew DeVore , Eric Wong , Matthieu Moy Subject: [PATCH 14/14] git-cvsexportcommit: port to SHA-256 Date: Fri, 19 Jun 2020 22:39:47 +0000 Message-Id: <20200619223947.947067-15-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.27.0.278.ge193c7cf3a9 In-Reply-To: <20200619223947.947067-1-sandals@crustytoothpaste.net> References: <20200619223947.947067-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 When we apply a binary patch, we must have the full object ID in the header in order to apply it; without that, any attempt to apply it will fail. If we set GIT_DIR to empty, git apply does not know about the hash algorithm we're using, and consequently any attempt to apply a patch using SHA-256 will fail, since the object ID is the wrong length. The reason we set the GIT_DIR environment variable is because we don't want to modify the index; we just want to know whether the patch applies. Instead, let's just use a temporary file for the index, which will be cleaned up automatically when the object goes out of scope. Additionally, read the configuration for the repository and compute the length of an object ID based on it. Use that when matching object IDs with a regex or computing the all-zeros object ID. Signed-off-by: brian m. carlson --- git-cvsexportcommit.perl | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl index fc00d5946a..6483d792d3 100755 --- a/git-cvsexportcommit.perl +++ b/git-cvsexportcommit.perl @@ -22,6 +22,10 @@ my $repo = Git->repository(); $opt_w = $repo->config('cvsexportcommit.cvsdir') unless defined $opt_w; +my $tmpdir = File::Temp->newdir; +my $hash_algo = $repo->config('extensions.objectformat') || 'sha1'; +my $hexsz = $hash_algo eq 'sha256' ? 64 : 40; + if ($opt_w || $opt_W) { # Remember where GIT_DIR is before changing to CVS checkout unless ($ENV{GIT_DIR}) { @@ -96,7 +100,7 @@ } if ($stage eq 'headers') { - if ($line =~ m/^parent (\w{40})$/) { # found a parent + if ($line =~ m/^parent ([0-9a-f]{$hexsz})$/) { # found a parent push @parents, $1; } elsif ($line =~ m/^author (.+) \d+ [-+]\d+$/) { $author = $1; @@ -111,7 +115,7 @@ } } -my $noparent = "0000000000000000000000000000000000000000"; +my $noparent = "0" x $hexsz; if ($parent) { my $found; # double check that it's a valid parent @@ -174,7 +178,7 @@ print "Checking if patch will apply\n"; my @stat; -open APPLY, "GIT_DIR= git-apply $context --summary --numstat<.cvsexportcommit.diff|" || die "cannot patch"; +open APPLY, "GIT_INDEX_FILE=$tmpdir/index git-apply $context --summary --numstat<.cvsexportcommit.diff|" || die "cannot patch"; @stat=; close APPLY || die "Cannot patch"; my (@bfiles,@files,@afiles,@dfiles); @@ -329,7 +333,7 @@ if ($opt_W) { system("git checkout -q $commit^0") && die "cannot patch"; } else { - `GIT_DIR= git-apply $context --summary --numstat --apply <.cvsexportcommit.diff` || die "cannot patch"; + `GIT_INDEX_FILE=$tmpdir/index git-apply $context --summary --numstat --apply <.cvsexportcommit.diff` || die "cannot patch"; } print "Patch applied successfully. Adding new files and directories to CVS\n"; @@ -407,7 +411,7 @@ if ($opt_W) { system("git checkout $go_back_to") && die "cannot move back to $go_back_to"; - if (!($go_back_to =~ /^[0-9a-fA-F]{40}$/)) { + if (!($go_back_to =~ /^[0-9a-fA-F]{$hexsz}$/)) { system("git symbolic-ref HEAD $go_back_to") && die "cannot move back to $go_back_to"; }