From patchwork Mon Oct 15 00:01: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: 10640943 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 48EBF925 for ; Mon, 15 Oct 2018 00:02:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 163872920C for ; Mon, 15 Oct 2018 00:02:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0AA70295EA; Mon, 15 Oct 2018 00:02: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 B27D0295EA for ; Mon, 15 Oct 2018 00:02:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726499AbeJOHpE (ORCPT ); Mon, 15 Oct 2018 03:45:04 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:50574 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726469AbeJOHpD (ORCPT ); Mon, 15 Oct 2018 03:45:03 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:90d0:bd19:fb95:28cb]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id CE79F61B81; Mon, 15 Oct 2018 00:02:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1539561739; bh=RlUXsatHq7KX+yJvyOwV+bf7cgYLyKyVsXAd+M4fSBQ=; 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=VYhZo9nrfzqAZO1NDBI3kBpBbDYLxhvBsQvCxyAi5JLU4etSBqZWKukxk52W/tN9O RkciD2os/wjrsS3ML+b7gXTIHg42fRZsEle6gZNGkvekzBxN4hyzonGIwGTo2u5wX9 KkHXcLlB4QwBHp4xh2BoD+tdycOSo7K2NhvG5dKqVDOVggXTQuLivaFiFEBE+cQnLM 8ZWEmfLyJ3yJacMpCuEl2Iym48Rx2vbNcKCE4g9RmNmNh36aMoVBpR0TBwraOqKu12 Rk/7KLrrZLgxLVfoGBxTqSytFQQcu0ME3d2tYVPjTFIFQaXAVcBPvlT1sYbeHOTwmD UlBY62q9fygILOVTunkqXxKnXbh0FMxS5YmAkz4fnrapeCLtuwO1gsdk1WW5YKl+AE +vW6U0VsKdbmpLkEJ3sJ101gEPuiGZeW4NrDTCF9xsxzZPADyHY84P+sWNNjF5ZShQ yS6IgccTDJQ6zVcCF9b6JeWRfTGwapX6aLcGg54IdHl4GAY6UCI From: "brian m. carlson" To: git@vger.kernel.org Cc: Jeff King , Eric Sunshine , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= , Stefan Beller Subject: [PATCH v2 07/15] packfile: express constants in terms of the_hash_algo Date: Mon, 15 Oct 2018 00:01:54 +0000 Message-Id: <20181015000202.951965-8-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.19.1.568.g152ad8e336 In-Reply-To: <20181015000202.951965-1-sandals@crustytoothpaste.net> References: <20181015000202.951965-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. It's likely that in the future, we'll update the pack format to indicate what hash algorithm it uses, and then this code will change. However, at least on an interim basis, make it easier to develop on a pure SHA-256 Git by using the_hash_algo here. 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++; }