From patchwork Mon Oct 8 21:56:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 10631525 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 183FB1867 for ; Mon, 8 Oct 2018 21:57:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0AF7829B4F for ; Mon, 8 Oct 2018 21:57:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F347D29B5F; Mon, 8 Oct 2018 21:57:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A556629B49 for ; Mon, 8 Oct 2018 21:57:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725898AbeJIFK7 (ORCPT ); Tue, 9 Oct 2018 01:10:59 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:49276 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbeJIFK6 (ORCPT ); Tue, 9 Oct 2018 01:10:58 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:e17d:6d35:bfb8:6a25]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id C1D5260780; Mon, 8 Oct 2018 21:57:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1539035829; bh=itxboVv5aGhsNiCg8QBzLprry8raGu4avShLEnv3Dgs=; 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=el35rmKtG24BxbZj3rR8iqretUfLq2UTdbMZpMgyb95NPOhgv5rcMDfzP+qsBIK24 TPG3CnviSHKUXzJa5ovqpNPeE40bY3Tr+UcoGNJdHeUWDxtAw9ePeK+ACWfR/g523t HWCQYPOS+KLqx+Y5t2q1V22P7RzxELuRNJFP1f/JZFCC9UV4m/DQAPBDc2JVIzEP6B tnay2z43B+TAK6u//0okupy9/pCiQkCqiggtC0OjfNthROl4KQzHac0i/hBRWMfYdi 0iXDgPNE7+t7zLwZvxKU3MNi2l6qWu9nX+FOyIIktdA2iMucaBhoZVrHBWXYk9E90c MohoG+yLNpMOFgDO/eKpy/3Vzbh3aMXIRfAFLCHEjGkobNY/TFpL/TzCU0hYFYBkPk ZRm8qxXF7b7aCqCSCAMSm/YvAI6+4gxLKW4KU+qKs4H2v32rxB9CTjt8pySttBKwCb lhpNKpdo3ydAcEde1jiYY9OZMVOwwhsLAnGw92jZ+5z5MqQveob From: "brian m. carlson" To: git@vger.kernel.org Cc: Jeff King , Eric Sunshine , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 01/14] pack-bitmap-write: use GIT_MAX_RAWSZ for allocation Date: Mon, 8 Oct 2018 21:56:48 +0000 Message-Id: <20181008215701.779099-2-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.19.1.331.ge82ca0e54c In-Reply-To: <20181008215701.779099-1-sandals@crustytoothpaste.net> References: <20181008215701.779099-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 127.0.1.1 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: brian m. carlson --- pack-bitmap-write.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c index fc82f37a02..6f0c78d6aa 100644 --- a/pack-bitmap-write.c +++ b/pack-bitmap-write.c @@ -37,7 +37,7 @@ struct bitmap_writer { struct progress *progress; int show_progress; - unsigned char pack_checksum[20]; + unsigned char pack_checksum[GIT_MAX_RAWSZ]; }; static struct bitmap_writer writer; From patchwork Mon Oct 8 21:56:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 10631527 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 449753CF1 for ; Mon, 8 Oct 2018 21:57:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36B6B29B4F for ; Mon, 8 Oct 2018 21:57:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B2B529B5F; Mon, 8 Oct 2018 21:57:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFA6529B45 for ; Mon, 8 Oct 2018 21:57:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725965AbeJIFK7 (ORCPT ); Tue, 9 Oct 2018 01:10:59 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:49284 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbeJIFK7 (ORCPT ); Tue, 9 Oct 2018 01:10:59 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:e17d:6d35:bfb8:6a25]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 9F35C60781; Mon, 8 Oct 2018 21:57:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1539035830; bh=xI933Yv4HTTGHwtAmfAMzhJcKKRVfaX87LLoz+jygIY=; 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=MmAUhWBgm8Kq600Wq4vrhK/5ZlEJivoSliLKbartNzGtbeYuDuh1nXt90NyeDuyBK QCmlu2lL2QeQEMCnw7PcDvSrNj5qKhirVmQ/AOYSauSHa/+VNmqf71RZwDMzsplQVE iBzFoD0NiQrxfYMqfTNo8jA6utOG1maKt4hzc282uVlIVS7jtP2+hzyEoK59ReuR73 RrdWt1EpqE+VOHrRY6ENKJyKzQOG+8I+B5vdbFZFI27cLZwRONlJaPmJqDFYAu+xiX x6a9wXr7x2ZeBHlD/oADw/3eJeMbZstDv32QqQApisuJU5gNHENteS3gsmK5efMGkZ FR7igGDRoAN8IkpdQH4ZWjiRhfj8x3qFuRQdNlaXj60a+Tswy1dDmmu01xOIQ0wr09 o6ANRxSabQemx1waGZbfl2xt38cQ7CmygqSs8F6CLbz6wTbl9sHzZA2pUP0BkNQYcD vSlDqJg6HPSr3z15YRhfbY6M1S8d0DooFI0q0KPj3V9V3WVCDEZ From: "brian m. carlson" To: git@vger.kernel.org Cc: Jeff King , Eric Sunshine , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 02/14] builtin/repack: replace hard-coded constant Date: Mon, 8 Oct 2018 21:56:49 +0000 Message-Id: <20181008215701.779099-3-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.19.1.331.ge82ca0e54c In-Reply-To: <20181008215701.779099-1-sandals@crustytoothpaste.net> References: <20181008215701.779099-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 127.0.1.1 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: brian m. carlson --- builtin/repack.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/repack.c b/builtin/repack.c index c6a7943d5c..e77859062d 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -407,8 +407,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix) out = xfdopen(cmd.out, "r"); while (strbuf_getline_lf(&line, out) != EOF) { - if (line.len != 40) - die("repack: Expecting 40 character sha1 lines only from pack-objects."); + if (line.len != the_hash_algo->hexsz) + die("repack: Expecting full hex object ID lines only from pack-objects."); string_list_append(&names, line.buf); } fclose(out); From patchwork Mon Oct 8 21:56:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 10631529 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7324715E8 for ; Mon, 8 Oct 2018 21:57:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62DF629B4F for ; Mon, 8 Oct 2018 21:57:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5773329B5F; Mon, 8 Oct 2018 21:57:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 057BB29B49 for ; Mon, 8 Oct 2018 21:57:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726160AbeJIFLB (ORCPT ); Tue, 9 Oct 2018 01:11:01 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:49294 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbeJIFLA (ORCPT ); Tue, 9 Oct 2018 01:11:00 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:e17d:6d35:bfb8:6a25]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 83CCB60782; Mon, 8 Oct 2018 21:57:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1539035831; bh=QTAeYojQOsmNZI0XOfqBrXs6MTsVfciEnFUO51RbfL0=; 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=gm2lFMIm2B1Ut8ODPAK+q4P3l1zTWqf0hg/H2WvXPJsqHcv5Bg4y6R0n62QBu5fBO bDpRyENis50pGCw0fxYTo7icYKjc4p2gPkOIy7VudFx4lyxz5Tqokd1dcR9o8End/Q svzzhqLhsKQeXks2VVMeiEhzUOgDqr/W6zyTpUfq2scM90Pw3U9ZF/spVZ5q4s+Lt3 9/U+AEajQQsMsiF/5P7OQbMXlfTtYr7qdkEQac8v1m063+6jWFAIja2xjDDy4rbWlw O8EKOzT+yWq2pcBKB6ayoYU/kxJAgXxk2j0Zxi1U64pMgpZPLR8k7IwLD7ZCK8Ycxo j3LX8n4WWx+yzxJAmpyX1xZp9BbZaPAPeQJ1Sm931JefliRd3OKuCUwakuIFIKDFJA j0+gqBSx/f+GcXUASrxiX8NASyRa1mbLHEukfxV6kHosHbvlcxFiXvzP5O29vsyO5w 2EkLSlyK9iXhMkxySxI6jDU+6DjEaxFYML7VcbXhmCTH6gw9rKy From: "brian m. carlson" To: git@vger.kernel.org Cc: Jeff King , Eric Sunshine , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 03/14] builtin/mktree: remove hard-coded constant Date: Mon, 8 Oct 2018 21:56:50 +0000 Message-Id: <20181008215701.779099-4-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.19.1.331.ge82ca0e54c In-Reply-To: <20181008215701.779099-1-sandals@crustytoothpaste.net> References: <20181008215701.779099-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 127.0.1.1 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of using a hard-coded constant for the size of a hex object ID, switch to use the computed pointer from parse_oid_hex that points after the parsed object ID. Signed-off-by: brian m. carlson --- builtin/mktree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/mktree.c b/builtin/mktree.c index 2dc4ad6ba8..94e82b8504 100644 --- a/builtin/mktree.c +++ b/builtin/mktree.c @@ -98,7 +98,7 @@ static void mktree_line(char *buf, size_t len, int nul_term_line, int allow_miss *ntr++ = 0; /* now at the beginning of SHA1 */ - path = ntr + 41; /* at the beginning of name */ + path = (char *)p + 1; /* at the beginning of name */ if (!nul_term_line && path[0] == '"') { struct strbuf p_uq = STRBUF_INIT; if (unquote_c_style(&p_uq, path, NULL)) From patchwork Mon Oct 8 21:56:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 10631531 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A48894B76 for ; Mon, 8 Oct 2018 21:57:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9314729B45 for ; Mon, 8 Oct 2018 21:57:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87E0B29B68; Mon, 8 Oct 2018 21:57:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 303DA29B45 for ; Mon, 8 Oct 2018 21:57:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726427AbeJIFLB (ORCPT ); Tue, 9 Oct 2018 01:11:01 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:49304 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725991AbeJIFLB (ORCPT ); Tue, 9 Oct 2018 01:11:01 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:e17d:6d35:bfb8:6a25]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 5747660783; Mon, 8 Oct 2018 21:57:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1539035831; bh=K13ZfQ45guTuC54UyPu3sK9+mK2LthXD+W7VT9EqKZU=; 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=G/7WXJBxR3cSCmY5YiIlK63HgpRLOokqkmbLpb9UXsQ8JJg1KqFfmQo8XaC+wqPRn Wh6JTxOBazZnfk2dwACrimZJKShu5axg3X1AXG8BfpAsi5kUOuEC+32L/tneGCuLuZ hmHs9wAvaFoVvfWfZLD+4BSQR8vPzEgYjGl/b5NliTpK56DKHN+grJZwYSp1sxTm/v PB3JQItsTrxwNjoIAAhMr6DNi7t69PHP6mG2oh7vjOcmfT2xck81NgYEt3T8+GkSfM hS8gwon6X4TcvATANv05lQdJBmEY+vVJQIXOvL1qYPw5vRueI5EoqfjkDr16ActrEZ Y4oaJhF2TSDnRPypTiO1qqNwVJlQVAmjsxTaek/EZMHEC3sv4HZgc6/sD8hW7RYp7R VpISQxkrkNrl4qFXt2ipCoTABvts6GUBMMHEqJKfifHN1zv15V/kyqN6mKww4McBpn J7IyUZpad5WcyY7iK9Ueof1RfBx7cDhI+lfPqZwCEeVkYtgYkQw From: "brian m. carlson" To: git@vger.kernel.org Cc: Jeff King , Eric Sunshine , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 04/14] builtin/fetch-pack: remove constants with parse_oid_hex Date: Mon, 8 Oct 2018 21:56:51 +0000 Message-Id: <20181008215701.779099-5-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.19.1.331.ge82ca0e54c In-Reply-To: <20181008215701.779099-1-sandals@crustytoothpaste.net> References: <20181008215701.779099-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 127.0.1.1 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of using GIT_SHA1_HEXSZ, use parse_oid_hex to compute a pointer and use that in comparisons. This is both simpler to read and works independent of the hash length. Update references to SHA-1 in the same function to refer to object IDs instead. Signed-off-by: brian m. carlson --- builtin/fetch-pack.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c index 1a1bc63566..63e69a5801 100644 --- a/builtin/fetch-pack.c +++ b/builtin/fetch-pack.c @@ -16,13 +16,14 @@ static void add_sought_entry(struct ref ***sought, int *nr, int *alloc, { struct ref *ref; struct object_id oid; + const char *p; - if (!get_oid_hex(name, &oid)) { - if (name[GIT_SHA1_HEXSZ] == ' ') { - /* , find refname */ - name += GIT_SHA1_HEXSZ + 1; - } else if (name[GIT_SHA1_HEXSZ] == '\0') { - ; /* , leave sha1 as name */ + if (!parse_oid_hex(name, &oid, &p)) { + if (*p == ' ') { + /* , find refname */ + name = p + 1; + } else if (*p == '\0') { + ; /* , leave oid as name */ } else { /* , clear cruft from oid */ oidclr(&oid); From patchwork Mon Oct 8 21:56:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 10631533 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C3D271867 for ; Mon, 8 Oct 2018 21:57:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B58A629B49 for ; Mon, 8 Oct 2018 21:57:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA63E29B45; Mon, 8 Oct 2018 21:57:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AE6A29B49 for ; Mon, 8 Oct 2018 21:57:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726491AbeJIFLC (ORCPT ); Tue, 9 Oct 2018 01:11:02 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:49306 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbeJIFLC (ORCPT ); Tue, 9 Oct 2018 01:11:02 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:e17d:6d35:bfb8:6a25]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 0FFB260784; Mon, 8 Oct 2018 21:57:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1539035832; bh=lcsHrRbs9M9fE7mF3WbALYaLs6cR//wh6ye8QfwrUM0=; 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=WRNHhkWXkV25j4WllKlJSXosHcZURJudcuNGTQMGZflRz+IrTQPKDkhSAohxldvRW 0jOBiyTimKA5e0l/B28a+kMwVzDHwjV99d6RpFgoFuv4ZaYcE1L9FXi5VJ3ig78yv4 yuPBdaYjqPAJeGwpRCmiGYj2ny0XLwCDKLFWN8pMnfQWR4ltpTVxdMGyfMFRXLhwsA PTUmnMB4ptWD/UJSqJ1D0rYLfToP6rJawMHc3bu5Q0/6SNwz2dYVJii4YiWYUxtQFX +9dwlNIZO2Auat4eeJbgxf/FBo2cqOIUckaKePNKlsqjM1esiCH/RHW5fszR0HN8An hU6+/H6Jhe5fLYA4XWzeBMO37lX0TJJmJBMLYvIVmqY2eFB+ouHl16DrRYJkxOc+AC Yad3EFNDc1cpzRmsUyy8RcaiYXv97bouNrw25yPlJhh8NZ5AEJfTY824oIZkjO8SJ4 lNJbPeb/UvyQ22xWlN/CexgEWXfniDx4N7Uyzv3kzYvdqpygtBk From: "brian m. carlson" To: git@vger.kernel.org Cc: Jeff King , Eric Sunshine , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 05/14] pack-revindex: express constants in terms of the_hash_algo Date: Mon, 8 Oct 2018 21:56:52 +0000 Message-Id: <20181008215701.779099-6-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.19.1.331.ge82ca0e54c In-Reply-To: <20181008215701.779099-1-sandals@crustytoothpaste.net> References: <20181008215701.779099-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 127.0.1.1 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Express the various constants used in terms of the_hash_algo. Signed-off-by: brian m. carlson --- pack-revindex.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pack-revindex.c b/pack-revindex.c index bb521cf7fb..3756ec71a8 100644 --- a/pack-revindex.c +++ b/pack-revindex.c @@ -122,13 +122,14 @@ static void create_pack_revindex(struct packed_git *p) unsigned num_ent = p->num_objects; unsigned i; const char *index = p->index_data; + const unsigned hashsz = the_hash_algo->rawsz; ALLOC_ARRAY(p->revindex, num_ent + 1); index += 4 * 256; if (p->index_version > 1) { const uint32_t *off_32 = - (uint32_t *)(index + 8 + p->num_objects * (20 + 4)); + (uint32_t *)(index + 8 + p->num_objects * (hashsz + 4)); const uint32_t *off_64 = off_32 + p->num_objects; for (i = 0; i < num_ent; i++) { uint32_t off = ntohl(*off_32++); @@ -142,16 +143,16 @@ static void create_pack_revindex(struct packed_git *p) } } else { for (i = 0; i < num_ent; i++) { - uint32_t hl = *((uint32_t *)(index + 24 * i)); + uint32_t hl = *((uint32_t *)(index + (hashsz + 4) * i)); p->revindex[i].offset = ntohl(hl); p->revindex[i].nr = i; } } - /* This knows the pack format -- the 20-byte trailer + /* This knows the pack format -- the hash trailer * follows immediately after the last object data. */ - p->revindex[num_ent].offset = p->pack_size - 20; + p->revindex[num_ent].offset = p->pack_size - hashsz; p->revindex[num_ent].nr = -1; sort_revindex(p->revindex, num_ent, p->pack_size); } From patchwork Mon Oct 8 21:56:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 10631535 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E07BD13AA for ; Mon, 8 Oct 2018 21:57:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0BA729B45 for ; Mon, 8 Oct 2018 21:57:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C55A129B5F; Mon, 8 Oct 2018 21:57:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8017729B4F for ; Mon, 8 Oct 2018 21:57:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726522AbeJIFLD (ORCPT ); Tue, 9 Oct 2018 01:11:03 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:49304 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725991AbeJIFLC (ORCPT ); Tue, 9 Oct 2018 01:11:02 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:e17d:6d35:bfb8:6a25]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id BEAD260785; Mon, 8 Oct 2018 21:57:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1539035833; bh=OLPMeu30RZzzRGj1yGvZ4CfO397lXKD+lFWsLUy79Rs=; 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=p/C3csPNHySYvtOjctJ8/kRV4sg6uHdLPO+4aM8kh3XYufbquoWljivMxtuzt/pWO QdBP29d/Qu7R5FgA80isfr6XUgL7cU9n9gLOtyJ6bRtc1pJM0EqfiOlr001VP84eCl uEvl135Tr5aSntL7g90f7id2oEHk3G4SLd5DJJ5KdQVYMM2Oc+/MaauzXeKbSxp70E lK1t+9P/msmcuQMf0wUxW3O+tY/70I3PuU7Qz+FN9v4UdHwHUtwPbkzLqYz9hsHSMY d9MjZnOTSw0FChCJF6ZdQee3kl/438GDVB9qQa8T8dS4JvwOobUFeVUUbStWimyAY6 ZsnrEpKxQezRrxtHneJ9YHcw9F+ar/6WolZ7d0mfoK94LB4dMgrsYHjTJ4ij6IAN5T E7eSi7xZBf9nzNAw978fltESU2PfBKs6kO0YF9o/UzqhSvmbNlJljIx22FjDY+rlHz YdMS8v762Mykvn0tycNV4uZsi2ScnteE2DAoe9tnVF8WqobNHU0 From: "brian m. carlson" To: git@vger.kernel.org Cc: Jeff King , Eric Sunshine , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 06/14] packfile: express constants in terms of the_hash_algo Date: Mon, 8 Oct 2018 21:56:53 +0000 Message-Id: <20181008215701.779099-7-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.19.1.331.ge82ca0e54c In-Reply-To: <20181008215701.779099-1-sandals@crustytoothpaste.net> References: <20181008215701.779099-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 127.0.1.1 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Replace uses of GIT_SHA1_RAWSZ with references to the_hash_algo to avoid dependence on a particular hash length. Signed-off-by: brian m. carlson --- packfile.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packfile.c b/packfile.c index 841b36182f..17f993b5bf 100644 --- a/packfile.c +++ b/packfile.c @@ -1121,13 +1121,14 @@ int unpack_object_header(struct packed_git *p, void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1) { unsigned i; + const unsigned hashsz = the_hash_algo->rawsz; for (i = 0; i < p->num_bad_objects; i++) - if (hasheq(sha1, p->bad_object_sha1 + GIT_SHA1_RAWSZ * i)) + if (hasheq(sha1, p->bad_object_sha1 + hashsz * i)) return; p->bad_object_sha1 = xrealloc(p->bad_object_sha1, st_mult(GIT_MAX_RAWSZ, st_add(p->num_bad_objects, 1))); - hashcpy(p->bad_object_sha1 + GIT_SHA1_RAWSZ * p->num_bad_objects, sha1); + hashcpy(p->bad_object_sha1 + hashsz * p->num_bad_objects, sha1); p->num_bad_objects++; } From patchwork Mon Oct 8 21:56:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 10631537 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1BA0C3CF1 for ; Mon, 8 Oct 2018 21:57:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F99429B4F for ; Mon, 8 Oct 2018 21:57:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0474E29B49; Mon, 8 Oct 2018 21:57:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0E3829B76 for ; Mon, 8 Oct 2018 21:57:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726525AbeJIFLE (ORCPT ); Tue, 9 Oct 2018 01:11:04 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:49306 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbeJIFLD (ORCPT ); Tue, 9 Oct 2018 01:11:03 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:e17d:6d35:bfb8:6a25]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 7258960789; Mon, 8 Oct 2018 21:57:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1539035833; bh=lk3zoBfcaMgdtZKQJfSk16mesbk7eXWLsgQNgRVDvjc=; 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=aDum+8f7wZkGfxI5LCE88Vs291/vjovLtfX1ktt/6lPIQUMSfhd4kpwT3wIauYfko z+5LHVvU/q8mN4l/vznZpv7uOfqzHpeRgQuE6i6D6EviuxFhK/KfnTT6mxgc6DugIQ w77PIsnPYmzyKDlUo4/9yDndLACyBsWqHQ6RmEdpALlv7njXfGqcfepoDqOJNhUIU2 g0Ni04uKTJbGg/AtmOpcVo1TeNYQijRq/w8yb1PAXCGnowQ1+Xo33QooDCTlUVuM76 4HsXNC52YFZ2gOr5GP55wmRPWYyzZy7vXbkSkyHEUhOyN2xznxvC0mquv4ywWGtBwK CzdOtKS0Ac7A6RADVQPxDLtZ4gIIJ5ph7cHs8Gs48s0VDHto1qfdAXbx55rLPsFpnL tnJqi84VYhFBiYeHPTpLIP/BUX5YBJmMUfxJa+Lh0WMyR7ETf8+XeAyFgH3PVe8cqJ AQVsoOHtd+KDgOUnMIDkfmckUGhROf4BGkmFTclaXOrQ0w2WY5I From: "brian m. carlson" To: git@vger.kernel.org Cc: Jeff King , Eric Sunshine , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 07/14] refs/packed-backend: express constants using the_hash_algo Date: Mon, 8 Oct 2018 21:56:54 +0000 Message-Id: <20181008215701.779099-8-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.19.1.331.ge82ca0e54c In-Reply-To: <20181008215701.779099-1-sandals@crustytoothpaste.net> References: <20181008215701.779099-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 127.0.1.1 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Switch uses of GIT_SHA1_HEXSZ to use the_hash_algo so that they are appropriate for the any given hash length. Signed-off-by: brian m. carlson --- refs/packed-backend.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/refs/packed-backend.c b/refs/packed-backend.c index 74e2996e93..c01c7f5901 100644 --- a/refs/packed-backend.c +++ b/refs/packed-backend.c @@ -274,8 +274,8 @@ struct snapshot_record { static int cmp_packed_ref_records(const void *v1, const void *v2) { const struct snapshot_record *e1 = v1, *e2 = v2; - const char *r1 = e1->start + GIT_SHA1_HEXSZ + 1; - const char *r2 = e2->start + GIT_SHA1_HEXSZ + 1; + const char *r1 = e1->start + the_hash_algo->hexsz + 1; + const char *r2 = e2->start + the_hash_algo->hexsz + 1; while (1) { if (*r1 == '\n') @@ -297,7 +297,7 @@ static int cmp_packed_ref_records(const void *v1, const void *v2) */ static int cmp_record_to_refname(const char *rec, const char *refname) { - const char *r1 = rec + GIT_SHA1_HEXSZ + 1; + const char *r1 = rec + the_hash_algo->hexsz + 1; const char *r2 = refname; while (1) { @@ -344,7 +344,7 @@ static void sort_snapshot(struct snapshot *snapshot) if (!eol) /* The safety check should prevent this. */ BUG("unterminated line found in packed-refs"); - if (eol - pos < GIT_SHA1_HEXSZ + 2) + if (eol - pos < the_hash_algo->hexsz + 2) die_invalid_line(snapshot->refs->path, pos, eof - pos); eol++; @@ -456,7 +456,7 @@ static void verify_buffer_safe(struct snapshot *snapshot) return; last_line = find_start_of_record(start, eof - 1); - if (*(eof - 1) != '\n' || eof - last_line < GIT_SHA1_HEXSZ + 2) + if (*(eof - 1) != '\n' || eof - last_line < the_hash_algo->hexsz + 2) die_invalid_line(snapshot->refs->path, last_line, eof - last_line); } @@ -796,7 +796,7 @@ static int next_record(struct packed_ref_iterator *iter) iter->base.flags = REF_ISPACKED; - if (iter->eof - p < GIT_SHA1_HEXSZ + 2 || + if (iter->eof - p < the_hash_algo->hexsz + 2 || parse_oid_hex(p, &iter->oid, &p) || !isspace(*p++)) die_invalid_line(iter->snapshot->refs->path, @@ -826,7 +826,7 @@ static int next_record(struct packed_ref_iterator *iter) if (iter->pos < iter->eof && *iter->pos == '^') { p = iter->pos + 1; - if (iter->eof - p < GIT_SHA1_HEXSZ + 1 || + if (iter->eof - p < the_hash_algo->hexsz + 1 || parse_oid_hex(p, &iter->peeled, &p) || *p++ != '\n') die_invalid_line(iter->snapshot->refs->path, From patchwork Mon Oct 8 21:56:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 10631539 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3CE8A15E8 for ; Mon, 8 Oct 2018 21:57:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D6F529B45 for ; Mon, 8 Oct 2018 21:57:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2195029B49; Mon, 8 Oct 2018 21:57:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1ACD29B68 for ; Mon, 8 Oct 2018 21:57:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726540AbeJIFLF (ORCPT ); Tue, 9 Oct 2018 01:11:05 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:49326 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbeJIFLF (ORCPT ); Tue, 9 Oct 2018 01:11:05 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:e17d:6d35:bfb8:6a25]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 4FCFA6078E; Mon, 8 Oct 2018 21:57:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1539035834; bh=TxBGW6kI35xH8pKYdfEu2uX8VVyCdYUbCN1x2GNYOVM=; 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=DpXisGmWh3wxT6+evMOl3TsQ4hl0XGqj21OgEew+aaLXf/wMqiBP02I8k3SBdExah 8ARDpdAW5oreQynafP4YLhulp1CLLebSiiNULKSUH41uTYwVBiSlO7psOWvH9bwszv mPEn8RL445JllEX0f0VlwvoKP9ILdHsByCeq7RWrZSKLTZNbq5IDLMVDYflPyZGoHD vLsMYM8NurVhigSkMOxdYCxC1J/bo0RwDjQHet8acSz1o8AjxvNr4k2Z4iSoBy4xet I2YgFxH+JiL9AN324njWwccoogmZ7L+K5FrFckLaKHVu29/ERL+Yg3IwJpsNNLgUwd KV49mYIPAT1Yi+d0YT2dStaSnsS1IHHC5mI1Jqi5rChPlyWpfrsY9f5SoBlScmW3mp lTsxLNALWBxMSnQOH+79Eb9AnkWNlV0Dt9sKseTH62SCupTNRKFUPXfVG6jku994Hu z8plfDJj1cj+OCsWgOANJBb1howEpteREYxTfQEPrQaMjK3DD3g From: "brian m. carlson" To: git@vger.kernel.org Cc: Jeff King , Eric Sunshine , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 08/14] upload-pack: express constants in terms of the_hash_algo Date: Mon, 8 Oct 2018 21:56:55 +0000 Message-Id: <20181008215701.779099-9-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.19.1.331.ge82ca0e54c In-Reply-To: <20181008215701.779099-1-sandals@crustytoothpaste.net> References: <20181008215701.779099-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 127.0.1.1 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Convert all uses of the GIT_SHA1_HEXSZ to use the_hash_algo so that they are appropriate for any given hash length. Signed-off-by: brian m. carlson --- upload-pack.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 62a1000f44..1aae5dd828 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -443,6 +443,7 @@ static int do_reachable_revlist(struct child_process *cmd, struct object *o; char namebuf[GIT_MAX_HEXSZ + 2]; /* ^ + hash + LF */ int i; + const unsigned hexsz = the_hash_algo->hexsz; cmd->argv = argv; cmd->git_cmd = 1; @@ -461,7 +462,7 @@ static int do_reachable_revlist(struct child_process *cmd, goto error; namebuf[0] = '^'; - namebuf[GIT_SHA1_HEXSZ + 1] = '\n'; + namebuf[hexsz + 1] = '\n'; for (i = get_max_object_index(); 0 < i; ) { o = get_indexed_object(--i); if (!o) @@ -470,11 +471,11 @@ static int do_reachable_revlist(struct child_process *cmd, o->flags &= ~TMP_MARK; if (!is_our_ref(o)) continue; - memcpy(namebuf + 1, oid_to_hex(&o->oid), GIT_SHA1_HEXSZ); - if (write_in_full(cmd->in, namebuf, GIT_SHA1_HEXSZ + 2) < 0) + memcpy(namebuf + 1, oid_to_hex(&o->oid), hexsz); + if (write_in_full(cmd->in, namebuf, hexsz + 2) < 0) goto error; } - namebuf[GIT_SHA1_HEXSZ] = '\n'; + namebuf[hexsz] = '\n'; for (i = 0; i < src->nr; i++) { o = src->objects[i].item; if (is_our_ref(o)) { @@ -484,8 +485,8 @@ static int do_reachable_revlist(struct child_process *cmd, } if (reachable && o->type == OBJ_COMMIT) o->flags |= TMP_MARK; - memcpy(namebuf, oid_to_hex(&o->oid), GIT_SHA1_HEXSZ); - if (write_in_full(cmd->in, namebuf, GIT_SHA1_HEXSZ + 1) < 0) + memcpy(namebuf, oid_to_hex(&o->oid), hexsz); + if (write_in_full(cmd->in, namebuf, hexsz + 1) < 0) goto error; } close(cmd->in); From patchwork Mon Oct 8 21:56:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 10631543 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DFC9B15E8 for ; Mon, 8 Oct 2018 21:57:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D238229B45 for ; Mon, 8 Oct 2018 21:57:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C68E629B4F; Mon, 8 Oct 2018 21:57:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A8B729B45 for ; Mon, 8 Oct 2018 21:57:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726579AbeJIFLJ (ORCPT ); Tue, 9 Oct 2018 01:11:09 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:49340 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725991AbeJIFLF (ORCPT ); Tue, 9 Oct 2018 01:11:05 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:e17d:6d35:bfb8:6a25]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 8B32160788; Mon, 8 Oct 2018 21:57:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1539035835; bh=VRLjC3u3UxT6bbCxIljy6X2n2kesAyJuv3+EwlcMsTA=; 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=xkHVrBD4WRkv/lVS83veKEcBy3v8vD1NwpMdB3m8L8nFp5HmrEY15lod+Iq4kfvCm nBeu3so8/Cc+U+CI68Mr/Yjkok5bwS/RsrMPToeOsvjJGoCtFb83NtVhBqB5EjMIF2 oNeHRR6JsuaZ3aAFPJhA8c3Ol8YGx+EA7LPugqdaNZ9gTEc1ft6LjtyQqBl0x4+96r cYRjwqV0fe52uBtkV3LvhJ/xT6fZwQH3+ik07auwQKQc148+JsI1qxxAZlzXf9dxKB QehLqRcdLJPn1SQKVSMFPYh6gk8jjxD7XxACFFb5P6iB23Z0VIEyeZZNjw/FSoJnop GSbY3grfhizyeeJ8AUQCLPeHrvEHXCBex5hyMR9y9DxcHgxYIUlGgALWLqhhEYg/hT d7sg1msMAU5G981InR/4xGa3vaCkk8eG22lfstEKezzvZ6uoR0JFY2NdnJWKiMV33C p/PxLsNnx7jzErOQwHyGdQZ1rk+8Q/Ybp7XV5BkJ/x1jp0KlEl6 From: "brian m. carlson" To: git@vger.kernel.org Cc: Jeff King , Eric Sunshine , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 09/14] transport: use parse_oid_hex instead of a constant Date: Mon, 8 Oct 2018 21:56:56 +0000 Message-Id: <20181008215701.779099-10-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.19.1.331.ge82ca0e54c In-Reply-To: <20181008215701.779099-1-sandals@crustytoothpaste.net> References: <20181008215701.779099-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 127.0.1.1 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use parse_oid_hex to compute a pointer instead of using GIT_SHA1_HEXSZ. This simplifies the code and makes it independent of the hash length. Signed-off-by: brian m. carlson --- transport.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/transport.c b/transport.c index 1c76d64aba..44b9ddf670 100644 --- a/transport.c +++ b/transport.c @@ -1346,15 +1346,16 @@ static void read_alternate_refs(const char *path, fh = xfdopen(cmd.out, "r"); while (strbuf_getline_lf(&line, fh) != EOF) { struct object_id oid; + const char *p; - if (get_oid_hex(line.buf, &oid) || - line.buf[GIT_SHA1_HEXSZ] != ' ') { + if (parse_oid_hex(line.buf, &oid, &p) || + *p != ' ') { warning(_("invalid line while parsing alternate refs: %s"), line.buf); break; } - cb(line.buf + GIT_SHA1_HEXSZ + 1, &oid, data); + cb(p + 1, &oid, data); } fclose(fh); From patchwork Mon Oct 8 21:56:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 10631541 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 86A1715E8 for ; Mon, 8 Oct 2018 21:57:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A1A629B45 for ; Mon, 8 Oct 2018 21:57:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E5B429B4F; Mon, 8 Oct 2018 21:57:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C9B229B45 for ; Mon, 8 Oct 2018 21:57:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726568AbeJIFLH (ORCPT ); Tue, 9 Oct 2018 01:11:07 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:49342 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbeJIFLG (ORCPT ); Tue, 9 Oct 2018 01:11:06 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:e17d:6d35:bfb8:6a25]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 41F3460791; Mon, 8 Oct 2018 21:57:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1539035836; bh=mjd0zMgzkK8tSp46oKlKDrn4KKPMjOt4j3PKVZ5QUzk=; 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=zPAMLASm+fzYQ/hT0z9Mv6Icm8DBv7prL2vy9ep0nU5p9uJuZmuaIM5i2ev9cdAG/ 28DSeNUGNWGgsod2Qj+mdcRypyaYYBWvJDNUaEgNe4Nw5AP5T8dkc7KPS8AoujAGj9 /aCuv9Fov8/z0CevSVFRkHa21R1WjfpELXcunbobiY563C41zsPp67uUwB6R6uiTVf uBd1rJtad93PVXJgXfu35gN3VcoWiEy3EWy1TLSj40P7u0tRDrrARLiLWGaGmmvww6 FE61VWzk9NecEGXPkp07yHzaIBsZfB8OjbOUACwSDz1jcuY9fZ6TpXpeKD7DN8zxWn zndXJwUrBKNeWOC9/eEg/IZCR8RMugNiQwAKfO7wNRdxnZKYXvqrhCc/8JMizHBrE5 HHjiv+FcOgLB3KryJUh9aXMT5T889KmJp2SyjyDjeYx23y1TZZ03AYqotwvZwo0Wtr 8RGHQnrHabHkJwpuR4mdLEOn4k4YEA0+AnMwibvJN5oCYj4Bltc From: "brian m. carlson" To: git@vger.kernel.org Cc: Jeff King , Eric Sunshine , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 10/14] tag: express constant in terms of the_hash_algo Date: Mon, 8 Oct 2018 21:56:57 +0000 Message-Id: <20181008215701.779099-11-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.19.1.331.ge82ca0e54c In-Reply-To: <20181008215701.779099-1-sandals@crustytoothpaste.net> References: <20181008215701.779099-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 127.0.1.1 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: brian m. carlson --- tag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tag.c b/tag.c index 1db663d716..7445b8f6ea 100644 --- a/tag.c +++ b/tag.c @@ -144,7 +144,7 @@ int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, u return 0; item->object.parsed = 1; - if (size < GIT_SHA1_HEXSZ + 24) + if (size < the_hash_algo->hexsz + 24) return -1; if (memcmp("object ", bufptr, 7) || parse_oid_hex(bufptr + 7, &oid, &bufptr) || *bufptr++ != '\n') return -1; From patchwork Mon Oct 8 21:56:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 10631545 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A569213AA for ; Mon, 8 Oct 2018 21:57:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9860229B45 for ; Mon, 8 Oct 2018 21:57:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C9DC29B4F; Mon, 8 Oct 2018 21:57:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 317D029B45 for ; Mon, 8 Oct 2018 21:57:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726625AbeJIFLK (ORCPT ); Tue, 9 Oct 2018 01:11:10 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:49354 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726607AbeJIFLK (ORCPT ); Tue, 9 Oct 2018 01:11:10 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:e17d:6d35:bfb8:6a25]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 7A54260789; Mon, 8 Oct 2018 21:57:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1539035837; bh=afA0DkEh9YgMBNUvx6855l6VhkWaEq+tcfJfnRC08EI=; 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=tk9g/wk1IaG1WJaTusPDaahNkfw/oPcDyQ2J52waHMTUZ1CI6VY9nHMWEh53j5O06 1zkr8kzficpzSxyZ+qSadCdQZT4nyI8JToWAFt3yD9tAevCy6+I+IvAav+MvhO4k1Y 4zPLbGZpEqkEetdD+GL7AAs+6RmIg4r9jifgAJgAOv8z2kAEAS+eChXaN+jPPIFdQm vE2fintGMnsN51vhSHoZlnklRKJiENQxrn3JbRk9tN86YduBj52xS8hfj27WTtKVVD I6tlh+aJkFX19q5T5lBlY8Rv9jBcw5SvkAUisCfzvlGncP7tcWFcOe03J4BHwjPLvK LSWg+5xrYmUi+HqpLYtxYGBV05JdyN/27+Sf0LFGywWTmwkIa39dEs2Tic4p7C3KlQ a+ajwXk60DR5fP5iDxw4yBOCzEGzeP/elhCstaIyG7+5wJ2zvcG235lb+BI/Ngs4r+ Nm8DiAwnfWGnx/rUsJ5+v+D3GSIrDaOBjo7DjrV3MXvujY48EeI From: "brian m. carlson" To: git@vger.kernel.org Cc: Jeff King , Eric Sunshine , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 11/14] apply: replace hard-coded constants Date: Mon, 8 Oct 2018 21:56:58 +0000 Message-Id: <20181008215701.779099-12-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.19.1.331.ge82ca0e54c In-Reply-To: <20181008215701.779099-1-sandals@crustytoothpaste.net> References: <20181008215701.779099-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 127.0.1.1 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Replace several 40-based constants with references to GIT_MAX_HEXSZ or the_hash_algo, as appropriate. Signed-off-by: brian m. carlson --- apply.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/apply.c b/apply.c index e485fbc6bc..792ecea36a 100644 --- a/apply.c +++ b/apply.c @@ -223,8 +223,8 @@ struct patch { struct fragment *fragments; char *result; size_t resultsize; - char old_sha1_prefix[41]; - char new_sha1_prefix[41]; + char old_sha1_prefix[GIT_MAX_HEXSZ + 1]; + char new_sha1_prefix[GIT_MAX_HEXSZ + 1]; struct patch *next; /* three-way fallback result */ @@ -1093,9 +1093,10 @@ static int gitdiff_index(struct apply_state *state, */ const char *ptr, *eol; int len; + const unsigned hexsz = the_hash_algo->hexsz; ptr = strchr(line, '.'); - if (!ptr || ptr[1] != '.' || 40 < ptr - line) + if (!ptr || ptr[1] != '.' || hexsz < ptr - line) return 0; len = ptr - line; memcpy(patch->old_sha1_prefix, line, len); @@ -1109,7 +1110,7 @@ static int gitdiff_index(struct apply_state *state, ptr = eol; len = ptr - line; - if (40 < len) + if (hexsz < len) return 0; memcpy(patch->new_sha1_prefix, line, len); patch->new_sha1_prefix[len] = 0; @@ -3142,13 +3143,14 @@ static int apply_binary(struct apply_state *state, { const char *name = patch->old_name ? patch->old_name : patch->new_name; struct object_id oid; + const unsigned hexsz = the_hash_algo->hexsz; /* * For safety, we require patch index line to contain - * full 40-byte textual SHA1 for old and new, at least for now. + * full hex textual object ID for old and new, at least for now. */ - if (strlen(patch->old_sha1_prefix) != 40 || - strlen(patch->new_sha1_prefix) != 40 || + if (strlen(patch->old_sha1_prefix) != hexsz || + strlen(patch->new_sha1_prefix) != hexsz || get_oid_hex(patch->old_sha1_prefix, &oid) || get_oid_hex(patch->new_sha1_prefix, &oid)) return error(_("cannot apply binary patch to '%s' " @@ -4055,7 +4057,7 @@ static int preimage_oid_in_gitlink_patch(struct patch *p, struct object_id *oid) starts_with(++preimage, heading) && /* does it record full SHA-1? */ !get_oid_hex(preimage + sizeof(heading) - 1, oid) && - preimage[sizeof(heading) + GIT_SHA1_HEXSZ - 1] == '\n' && + preimage[sizeof(heading) + the_hash_algo->hexsz - 1] == '\n' && /* does the abbreviated name on the index line agree with it? */ starts_with(preimage + sizeof(heading) - 1, p->old_sha1_prefix)) return 0; /* it all looks fine */ From patchwork Mon Oct 8 21:56:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 10631547 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D4D9415E8 for ; Mon, 8 Oct 2018 21:57:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7AF829B45 for ; Mon, 8 Oct 2018 21:57:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC40F29B4F; Mon, 8 Oct 2018 21:57:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 382B729B45 for ; Mon, 8 Oct 2018 21:57:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726656AbeJIFLM (ORCPT ); Tue, 9 Oct 2018 01:11:12 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:49360 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725991AbeJIFLL (ORCPT ); Tue, 9 Oct 2018 01:11:11 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:e17d:6d35:bfb8:6a25]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 279B56079C; Mon, 8 Oct 2018 21:57:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1539035840; bh=Mi/LPpAhVdZfMLtx1DCYc5Trh8mZP5nPrkqMHP5g8BI=; 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=JuLD+56G0/LsxqEAYQOsodn54jeKK3a/4AWfWNEwVVAo2UvuRduzZDj45EBzaTMUS m+loLwpRTC6ySO18pPUTrHHX9CIp20zfGkQ3Qy28ja5OgoztdcEkN5/OQKneGGI4Ag YJiwrX3aqTgLbLW87wuyh+gRbMQ5suAb2TxuaG14G1tQh/Wvdi6dXK5CMQD2QolsBs uoIN7+JbVJtbEGabJQ2UXXrKWcRwIZw85VSe1647fBDIJYkuPEOzVrmGXmA/J1aAzx ONfhkHNzMDRbLZCGR+JpjYSxZkTmmZBW0I8DWZL/u7Xd+oVOFJEkAsPYIv3E5fryNJ yoFfK0EZZsVizdP5zQIpt8QQ8RwIlanL4lxtLJimmFFOhQnh0HHsAy3HICyedcNcf7 79TRsqjqUPmTUwz5oGxgeEGGhG87qb1thR9r3bwzLxzgwml79mVg8BCOejMsJUBbfv QYuGymTEJWM7dElaekiB62bfyfpiZoM6qQbnw+uD6xVccjdpasu From: "brian m. carlson" To: git@vger.kernel.org Cc: Jeff King , Eric Sunshine , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 12/14] apply: rename new_sha1_prefix and old_sha1_prefix Date: Mon, 8 Oct 2018 21:56:59 +0000 Message-Id: <20181008215701.779099-13-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.19.1.331.ge82ca0e54c In-Reply-To: <20181008215701.779099-1-sandals@crustytoothpaste.net> References: <20181008215701.779099-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 127.0.1.1 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Rename these structure members to "new_oid_prefix" and "old_oid_prefix". Signed-off-by: brian m. carlson --- apply.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/apply.c b/apply.c index 792ecea36a..b9eb02ec12 100644 --- a/apply.c +++ b/apply.c @@ -223,8 +223,8 @@ struct patch { struct fragment *fragments; char *result; size_t resultsize; - char old_sha1_prefix[GIT_MAX_HEXSZ + 1]; - char new_sha1_prefix[GIT_MAX_HEXSZ + 1]; + char old_oid_prefix[GIT_MAX_HEXSZ + 1]; + char new_oid_prefix[GIT_MAX_HEXSZ + 1]; struct patch *next; /* three-way fallback result */ @@ -1099,8 +1099,8 @@ static int gitdiff_index(struct apply_state *state, if (!ptr || ptr[1] != '.' || hexsz < ptr - line) return 0; len = ptr - line; - memcpy(patch->old_sha1_prefix, line, len); - patch->old_sha1_prefix[len] = 0; + memcpy(patch->old_oid_prefix, line, len); + patch->old_oid_prefix[len] = 0; line = ptr + 2; ptr = strchr(line, ' '); @@ -1112,8 +1112,8 @@ static int gitdiff_index(struct apply_state *state, if (hexsz < len) return 0; - memcpy(patch->new_sha1_prefix, line, len); - patch->new_sha1_prefix[len] = 0; + memcpy(patch->new_oid_prefix, line, len); + patch->new_oid_prefix[len] = 0; if (*ptr == ' ') return gitdiff_oldmode(state, ptr + 1, patch); return 0; @@ -2205,7 +2205,7 @@ static void reverse_patches(struct patch *p) SWAP(p->new_mode, p->old_mode); SWAP(p->is_new, p->is_delete); SWAP(p->lines_added, p->lines_deleted); - SWAP(p->old_sha1_prefix, p->new_sha1_prefix); + SWAP(p->old_oid_prefix, p->new_oid_prefix); for (; frag; frag = frag->next) { SWAP(frag->newpos, frag->oldpos); @@ -3149,10 +3149,10 @@ static int apply_binary(struct apply_state *state, * For safety, we require patch index line to contain * full hex textual object ID for old and new, at least for now. */ - if (strlen(patch->old_sha1_prefix) != hexsz || - strlen(patch->new_sha1_prefix) != hexsz || - get_oid_hex(patch->old_sha1_prefix, &oid) || - get_oid_hex(patch->new_sha1_prefix, &oid)) + if (strlen(patch->old_oid_prefix) != hexsz || + strlen(patch->new_oid_prefix) != hexsz || + get_oid_hex(patch->old_oid_prefix, &oid) || + get_oid_hex(patch->new_oid_prefix, &oid)) return error(_("cannot apply binary patch to '%s' " "without full index line"), name); @@ -3162,7 +3162,7 @@ static int apply_binary(struct apply_state *state, * applies to. */ hash_object_file(img->buf, img->len, blob_type, &oid); - if (strcmp(oid_to_hex(&oid), patch->old_sha1_prefix)) + if (strcmp(oid_to_hex(&oid), patch->old_oid_prefix)) return error(_("the patch applies to '%s' (%s), " "which does not match the " "current contents."), @@ -3175,7 +3175,7 @@ static int apply_binary(struct apply_state *state, "'%s' but it is not empty"), name); } - get_oid_hex(patch->new_sha1_prefix, &oid); + get_oid_hex(patch->new_oid_prefix, &oid); if (is_null_oid(&oid)) { clear_image(img); return 0; /* deletion patch */ @@ -3191,7 +3191,7 @@ static int apply_binary(struct apply_state *state, if (!result) return error(_("the necessary postimage %s for " "'%s' cannot be read"), - patch->new_sha1_prefix, name); + patch->new_oid_prefix, name); clear_image(img); img->buf = result; img->len = size; @@ -3207,9 +3207,9 @@ static int apply_binary(struct apply_state *state, /* verify that the result matches */ hash_object_file(img->buf, img->len, blob_type, &oid); - if (strcmp(oid_to_hex(&oid), patch->new_sha1_prefix)) + if (strcmp(oid_to_hex(&oid), patch->new_oid_prefix)) return error(_("binary patch to '%s' creates incorrect result (expecting %s, got %s)"), - name, patch->new_sha1_prefix, oid_to_hex(&oid)); + name, patch->new_oid_prefix, oid_to_hex(&oid)); } return 0; @@ -3565,7 +3565,7 @@ static int try_threeway(struct apply_state *state, /* Preimage the patch was prepared for */ if (patch->is_new) write_object_file("", 0, blob_type, &pre_oid); - else if (get_oid(patch->old_sha1_prefix, &pre_oid) || + else if (get_oid(patch->old_oid_prefix, &pre_oid) || read_blob_object(&buf, &pre_oid, patch->old_mode)) return error(_("repository lacks the necessary blob to fall back on 3-way merge.")); @@ -4059,11 +4059,11 @@ static int preimage_oid_in_gitlink_patch(struct patch *p, struct object_id *oid) !get_oid_hex(preimage + sizeof(heading) - 1, oid) && preimage[sizeof(heading) + the_hash_algo->hexsz - 1] == '\n' && /* does the abbreviated name on the index line agree with it? */ - starts_with(preimage + sizeof(heading) - 1, p->old_sha1_prefix)) + starts_with(preimage + sizeof(heading) - 1, p->old_oid_prefix)) return 0; /* it all looks fine */ /* we may have full object name on the index line */ - return get_oid_hex(p->old_sha1_prefix, oid); + return get_oid_hex(p->old_oid_prefix, oid); } /* Build an index that contains just the files needed for a 3way merge */ @@ -4092,7 +4092,7 @@ static int build_fake_ancestor(struct apply_state *state, struct patch *list) else return error(_("sha1 information is lacking or " "useless for submodule %s"), name); - } else if (!get_oid_blob(patch->old_sha1_prefix, &oid)) { + } else if (!get_oid_blob(patch->old_oid_prefix, &oid)) { ; /* ok */ } else if (!patch->lines_added && !patch->lines_deleted) { /* mode-only change: update the current */ From patchwork Mon Oct 8 21:57:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 10631549 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 43B581867 for ; Mon, 8 Oct 2018 21:57:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36B1029B45 for ; Mon, 8 Oct 2018 21:57:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B07429B49; Mon, 8 Oct 2018 21:57:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9F6229B73 for ; Mon, 8 Oct 2018 21:57:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726683AbeJIFLM (ORCPT ); Tue, 9 Oct 2018 01:11:12 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:49368 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726607AbeJIFLM (ORCPT ); Tue, 9 Oct 2018 01:11:12 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:e17d:6d35:bfb8:6a25]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 90D0A60795; Mon, 8 Oct 2018 21:57:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1539035842; bh=KMHOFhDhs+e8XG79HA2fwqObXCKP54IxtSABSA7ldwk=; 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=p26fCrdI+J145aIthnaMHfvKDmYkRTdI8ybs+gR6PqEP0nQIkyioGqqDhQ5Ti1rEh aI3MDhghtC/hYFOkbD4F8Ui+13I98WsfTSj8RKw76A0NFd+xPYkTlTcHiKtaIT9SSH YRWQFcVQEwd6tdBumGv06TRlvgLi0aAj0Urn5oXyqbUgYGxGAEH11xi74ySblBnx/f b2pWy3p9ZbaMkUu1rrh3dWd2/cdVUpoMwV9wM7RO7DDsG/q4x8GiWiCTs+bjHfvk73 R8+lHNNnVFap1c7lPnTjtzj5DIozSm4KozXNmBjAMbNfVdo1E345JzerfdvTGzD+rC 4HQMH+nGwIGpxyWbp3Fpkup52xz0xgphDxF32Q+Bd3g1EVo0PJ537s8lS9jlMwkE+H VlNzFFpmqw1rod2zXCvVi6LDuu94lOywR/k/jIHeMU1fW6xeykI60+aPPtXHCYtYES m5pZpdee+pOLb0973kicGd3sIk8lVClBRNAxg2SVA31o4w6ARMP From: "brian m. carlson" To: git@vger.kernel.org Cc: Jeff King , Eric Sunshine , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 13/14] submodule: make zero-oid comparison hash function agnostic Date: Mon, 8 Oct 2018 21:57:00 +0000 Message-Id: <20181008215701.779099-14-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.19.1.331.ge82ca0e54c In-Reply-To: <20181008215701.779099-1-sandals@crustytoothpaste.net> References: <20181008215701.779099-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 127.0.1.1 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With SHA-256, the length of the all-zeros object ID is longer. Add a function to git-submodule.sh to check if a full hex object ID is the all-zeros value, and use it to check the output we're parsing from git diff-files or diff-index. Signed-off-by: brian m. carlson --- git-submodule.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/git-submodule.sh b/git-submodule.sh index 1b568e29b9..c09eb3e03d 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -82,6 +82,11 @@ isnumber() n=$(($1 + 0)) 2>/dev/null && test "$n" = "$1" } +# Given a full hex object ID, is this the zero OID? +is_zero_oid () { + echo "$1" | sane_egrep '^0+$' >/dev/null 2>&1 +} + # Sanitize the local git environment for use within a submodule. We # can't simply use clear_local_git_env since we want to preserve some # of the settings from GIT_CONFIG_PARAMETERS. @@ -780,7 +785,7 @@ cmd_summary() { while read -r mod_src mod_dst sha1_src sha1_dst status name do if test -z "$cached" && - test $sha1_dst = 0000000000000000000000000000000000000000 + is_zero_oid $sha1_dst then case "$mod_dst" in 160000) From patchwork Mon Oct 8 21:57:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 10631551 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F1A2513AA for ; Mon, 8 Oct 2018 21:57:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E293329B45 for ; Mon, 8 Oct 2018 21:57:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6A7629B4F; Mon, 8 Oct 2018 21:57:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12D2B29B45 for ; Mon, 8 Oct 2018 21:57:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726700AbeJIFLP (ORCPT ); Tue, 9 Oct 2018 01:11:15 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:49376 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726607AbeJIFLP (ORCPT ); Tue, 9 Oct 2018 01:11:15 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:e17d:6d35:bfb8:6a25]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id C92FD607A0; Mon, 8 Oct 2018 21:57:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1539035843; bh=OC3fDgp4b9OsHC6sXy2aqapI/WcpRWU711G1JorbVsM=; 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=AblRorKdjLLuycXkYXpXB42tsloS9XdNVPKmTxKs4DZLUq+7T11+8JkDFyvFibq6T lfpYntQttDs3n61jCuqPFIOlVAZCwSw/k4gaJwIWy0UdlHky/YjnTRJANHREjym9Yd RqpZbKduI7UZRSnXJ1HtHSXK9gP3FduBm8RcQ8nbUoIBwSxtL65Gmm0/lo/4qzHKe/ 38MO0R69nqE/r6D8dPssanXHRusI3cVmhpRhi6EVu8eT3Eo2VSG6W3QNKQciyPZQoM XEyCB4ZkpWWkg/Ly5jvObZIcFGo0Dgc7rI2+kUE9zaFUcGAIFZMitIVdake2VzUL8+ Sfo1bWVDRGDqiTRixu6hTUgUlKP+8JxC1OZ68sIDcwREWNSPtEWSNQfhp8avWTNwBo NlNvKl48vqCp2HzstvJIUvZ8N5Bel57zTmVjs1midyLiO50RpyNoiyTuoq+ll4JSgZ mMDHV7e203EqhlSI3J2V4fj6FJA32ZrA9kCZ1xhgF5z33foeoeA From: "brian m. carlson" To: git@vger.kernel.org Cc: Jeff King , Eric Sunshine , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 14/14] rerere: convert to use the_hash_algo Date: Mon, 8 Oct 2018 21:57:01 +0000 Message-Id: <20181008215701.779099-15-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.19.1.331.ge82ca0e54c In-Reply-To: <20181008215701.779099-1-sandals@crustytoothpaste.net> References: <20181008215701.779099-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 127.0.1.1 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since this data is stored in the .git directory, it makes sense for us to use the same hash algorithm for it as for everything else. Convert the remaining uses of SHA-1 to use the_hash_algo. Use GIT_MAX_RAWSZ for allocations. Rename various struct members, local variables, and a function to be named "hash" instead of "sha1". Signed-off-by: brian m. carlson --- rerere.c | 81 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/rerere.c b/rerere.c index 7aa149e849..ceb98015ff 100644 --- a/rerere.c +++ b/rerere.c @@ -29,7 +29,7 @@ static int rerere_dir_alloc; #define RR_HAS_POSTIMAGE 1 #define RR_HAS_PREIMAGE 2 static struct rerere_dir { - unsigned char sha1[20]; + unsigned char hash[GIT_MAX_HEXSZ]; int status_alloc, status_nr; unsigned char *status; } **rerere_dir; @@ -52,7 +52,7 @@ static void free_rerere_id(struct string_list_item *item) static const char *rerere_id_hex(const struct rerere_id *id) { - return sha1_to_hex(id->collection->sha1); + return sha1_to_hex(id->collection->hash); } static void fit_variant(struct rerere_dir *rr_dir, int variant) @@ -115,7 +115,7 @@ static int is_rr_file(const char *name, const char *filename, int *variant) static void scan_rerere_dir(struct rerere_dir *rr_dir) { struct dirent *de; - DIR *dir = opendir(git_path("rr-cache/%s", sha1_to_hex(rr_dir->sha1))); + DIR *dir = opendir(git_path("rr-cache/%s", sha1_to_hex(rr_dir->hash))); if (!dir) return; @@ -133,24 +133,24 @@ static void scan_rerere_dir(struct rerere_dir *rr_dir) closedir(dir); } -static const unsigned char *rerere_dir_sha1(size_t i, void *table) +static const unsigned char *rerere_dir_hash(size_t i, void *table) { struct rerere_dir **rr_dir = table; - return rr_dir[i]->sha1; + return rr_dir[i]->hash; } static struct rerere_dir *find_rerere_dir(const char *hex) { - unsigned char sha1[20]; + unsigned char hash[GIT_MAX_RAWSZ]; struct rerere_dir *rr_dir; int pos; - if (get_sha1_hex(hex, sha1)) + if (get_sha1_hex(hex, hash)) return NULL; /* BUG */ - pos = sha1_pos(sha1, rerere_dir, rerere_dir_nr, rerere_dir_sha1); + pos = sha1_pos(hash, rerere_dir, rerere_dir_nr, rerere_dir_hash); if (pos < 0) { rr_dir = xmalloc(sizeof(*rr_dir)); - hashcpy(rr_dir->sha1, sha1); + hashcpy(rr_dir->hash, hash); rr_dir->status = NULL; rr_dir->status_nr = 0; rr_dir->status_alloc = 0; @@ -207,26 +207,27 @@ static void read_rr(struct string_list *rr) return; while (!strbuf_getwholeline(&buf, in, '\0')) { char *path; - unsigned char sha1[20]; + unsigned char hash[GIT_MAX_RAWSZ]; struct rerere_id *id; int variant; + const unsigned hexsz = the_hash_algo->hexsz; /* There has to be the hash, tab, path and then NUL */ - if (buf.len < 42 || get_sha1_hex(buf.buf, sha1)) + if (buf.len < hexsz + 2 || get_sha1_hex(buf.buf, hash)) die(_("corrupt MERGE_RR")); - if (buf.buf[40] != '.') { + if (buf.buf[hexsz] != '.') { variant = 0; - path = buf.buf + 40; + path = buf.buf + hexsz; } else { errno = 0; - variant = strtol(buf.buf + 41, &path, 10); + variant = strtol(buf.buf + hexsz + 1, &path, 10); if (errno) die(_("corrupt MERGE_RR")); } if (*(path++) != '\t') die(_("corrupt MERGE_RR")); - buf.buf[40] = '\0'; + buf.buf[hexsz] = '\0'; id = new_rerere_id_hex(buf.buf); id->variant = variant; string_list_insert(rr, path)->util = id; @@ -360,7 +361,7 @@ static void rerere_strbuf_putconflict(struct strbuf *buf, int ch, size_t size) } static int handle_conflict(struct strbuf *out, struct rerere_io *io, - int marker_size, git_SHA_CTX *ctx) + int marker_size, git_hash_ctx *ctx) { enum { RR_SIDE_1 = 0, RR_SIDE_2, RR_ORIGINAL @@ -398,10 +399,12 @@ static int handle_conflict(struct strbuf *out, struct rerere_io *io, strbuf_addbuf(out, &two); rerere_strbuf_putconflict(out, '>', marker_size); if (ctx) { - git_SHA1_Update(ctx, one.buf ? one.buf : "", - one.len + 1); - git_SHA1_Update(ctx, two.buf ? two.buf : "", - two.len + 1); + the_hash_algo->update_fn(ctx, one.buf ? + one.buf : "", + one.len + 1); + the_hash_algo->update_fn(ctx, two.buf ? + two.buf : "", + two.len + 1); } break; } else if (hunk == RR_SIDE_1) @@ -430,18 +433,18 @@ static int handle_conflict(struct strbuf *out, struct rerere_io *io, * Return 1 if conflict hunks are found, 0 if there are no conflict * hunks and -1 if an error occured. */ -static int handle_path(unsigned char *sha1, struct rerere_io *io, int marker_size) +static int handle_path(unsigned char *hash, struct rerere_io *io, int marker_size) { - git_SHA_CTX ctx; + git_hash_ctx ctx; struct strbuf buf = STRBUF_INIT, out = STRBUF_INIT; int has_conflicts = 0; - if (sha1) - git_SHA1_Init(&ctx); + if (hash) + the_hash_algo->init_fn(&ctx); while (!io->getline(&buf, io)) { if (is_cmarker(buf.buf, '<', marker_size)) { has_conflicts = handle_conflict(&out, io, marker_size, - sha1 ? &ctx : NULL); + hash ? &ctx : NULL); if (has_conflicts < 0) break; rerere_io_putmem(out.buf, out.len, io); @@ -452,8 +455,8 @@ static int handle_path(unsigned char *sha1, struct rerere_io *io, int marker_siz strbuf_release(&buf); strbuf_release(&out); - if (sha1) - git_SHA1_Final(sha1, &ctx); + if (hash) + the_hash_algo->final_fn(hash, &ctx); return has_conflicts; } @@ -462,7 +465,7 @@ static int handle_path(unsigned char *sha1, struct rerere_io *io, int marker_siz * Scan the path for conflicts, do the "handle_path()" thing above, and * return the number of conflict hunks found. */ -static int handle_file(const char *path, unsigned char *sha1, const char *output) +static int handle_file(const char *path, unsigned char *hash, const char *output) { int has_conflicts = 0; struct rerere_io_file io; @@ -484,7 +487,7 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output } } - has_conflicts = handle_path(sha1, (struct rerere_io *)&io, marker_size); + has_conflicts = handle_path(hash, (struct rerere_io *)&io, marker_size); fclose(io.input); if (io.io.wrerror) @@ -814,7 +817,7 @@ static int do_plain_rerere(struct string_list *rr, int fd) */ for (i = 0; i < conflict.nr; i++) { struct rerere_id *id; - unsigned char sha1[20]; + unsigned char hash[GIT_MAX_RAWSZ]; const char *path = conflict.items[i].string; int ret; @@ -823,7 +826,7 @@ static int do_plain_rerere(struct string_list *rr, int fd) * conflict ID. No need to write anything out * yet. */ - ret = handle_file(path, sha1, NULL); + ret = handle_file(path, hash, NULL); if (ret != 0 && string_list_has_string(rr, path)) { remove_variant(string_list_lookup(rr, path)->util); string_list_remove(rr, path, 1); @@ -831,7 +834,7 @@ static int do_plain_rerere(struct string_list *rr, int fd) if (ret < 1) continue; - id = new_rerere_id(sha1); + id = new_rerere_id(hash); string_list_insert(rr, path)->util = id; /* Ensure that the directory exists. */ @@ -942,7 +945,7 @@ static int rerere_mem_getline(struct strbuf *sb, struct rerere_io *io_) return 0; } -static int handle_cache(const char *path, unsigned char *sha1, const char *output) +static int handle_cache(const char *path, unsigned char *hash, const char *output) { mmfile_t mmfile[3] = {{NULL}}; mmbuffer_t result = {NULL, 0}; @@ -1001,7 +1004,7 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu * Grab the conflict ID and optionally write the original * contents with conflict markers out. */ - has_conflicts = handle_path(sha1, (struct rerere_io *)&io, marker_size); + has_conflicts = handle_path(hash, (struct rerere_io *)&io, marker_size); strbuf_release(&io.input); if (io.io.output) fclose(io.io.output); @@ -1012,7 +1015,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr) { const char *filename; struct rerere_id *id; - unsigned char sha1[20]; + unsigned char hash[GIT_MAX_RAWSZ]; int ret; struct string_list_item *item; @@ -1020,12 +1023,12 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr) * Recreate the original conflict from the stages in the * index and compute the conflict ID */ - ret = handle_cache(path, sha1, NULL); + ret = handle_cache(path, hash, NULL); if (ret < 1) return error(_("could not parse conflict hunks in '%s'"), path); /* Nuke the recorded resolution for the conflict */ - id = new_rerere_id(sha1); + id = new_rerere_id(hash); for (id->variant = 0; id->variant < id->collection->status_nr; @@ -1037,7 +1040,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr) if (!has_rerere_resolution(id)) continue; - handle_cache(path, sha1, rerere_path(id, "thisimage")); + handle_cache(path, hash, rerere_path(id, "thisimage")); if (read_mmfile(&cur, rerere_path(id, "thisimage"))) { free(cur.ptr); error(_("failed to update conflicted state in '%s'"), path); @@ -1069,7 +1072,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr) * conflict in the working tree, run us again to record * the postimage. */ - handle_cache(path, sha1, rerere_path(id, "preimage")); + handle_cache(path, hash, rerere_path(id, "preimage")); fprintf_ln(stderr, _("Updated preimage for '%s'"), path); /*