From patchwork Tue Jun 11 11:58:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13693586 Received: from wfout5-smtp.messagingengine.com (wfout5-smtp.messagingengine.com [64.147.123.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DCD7117C20E for ; Tue, 11 Jun 2024 11:58:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.148 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718107119; cv=none; b=RkgFKGMz6uhjsDfExdvA1DyymhbTLxA5BbBLKs1sZzewxXEofAjrYchni1NP2C4oqOw1jcT5l+NIeHQDfP0bVmLri6/Rbgcc831ksJpAejvMjl4D0QQExd26RALQbi5V5sVZC/DdtPEUgVM/7gIr85FnDRPhmcB3EvwdN2YHvTs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718107119; c=relaxed/simple; bh=lP9MDDQZ0IJNf+/pNaoaMIIbN2irhWPTWzS+wlSQAgA=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mPO0JOiBhaaRedpC6KnFDf7qLfsPyQER4K+U7Yrshe2SLSwNOOcwvuRZRfZmpBYEukWXf4H21DBksa7ABGIaaZp9bgjrfeDbPnturqpuo6H5G+qjc4VJBxJpMwiGauVm3Vct3MbuuF2dl3wbqQtNdJLNqbTEJstvzQ9gcZe12sk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=Cs/talYR; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=AfLMd1Gk; arc=none smtp.client-ip=64.147.123.148 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="Cs/talYR"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="AfLMd1Gk" Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfout.west.internal (Postfix) with ESMTP id 0F6781C000EC for ; Tue, 11 Jun 2024 07:58:36 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Tue, 11 Jun 2024 07:58:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1718107116; x=1718193516; bh=4bJFESBao8 RCw4cLV52nC63rStX2erUyAqLGDdnmiD4=; b=Cs/talYRBZuk/4g4Mo2bXZGGfF H8sJi7Z1LWBu7XqVOd+oEwMmwskA2OBEP0+13fuUc7QOJRBZltPGOGu2E/TXW/f0 T995tjHH4CbxDntiZ9HZTXU6rBzlBsgnwlYTxDD+w/d8zbvxZG1Y+URgoA/U+2jI SnVDVuhMcw2fDO2XQVrqmvQAVeQmo+qNVZr034TeHSlj9hQJNJ65/bJTh+ldXdpP PfP1qsmUurUu74t1R6Y5TpVT/UmLY8LzaZLBQ/LJ1wcL5A7zxHeblThwqnS0PP/A uRDjV1y+x6q2d2k66FPLf99CYIBbxgEqoE6KiUk8Wf11LIW5NL0/4E6gn9pg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1718107116; x=1718193516; bh=4bJFESBao8RCw4cLV52nC63rStX2 erUyAqLGDdnmiD4=; b=AfLMd1GkuP0KIEBWuKn8tQvZf5fpGFGRW5JhCISmATjm GA6ErIt+FP4ejy5moshILXrOI+H8oj51mal4RnujepgUO4Tyf8JBoYnbRzgW2e9K v/lhURWdkCKbXS/YbDshZ+kHXG1k3vZ9jlrwiBILkwC3iCA9oLirAO030pCVNr93 4Ia7bGBOm7vJwSmDsBBsngb685L/NpeDmX5yU+uWUdVrIi/Chs+3wD1FAAjvK6NH 7upRjia6sHLorNTgfu5nZxxPUaq36wp0d8YCypfRe0xq7cCCEKrS6TfoOx4YiW7b YaSsFaaxHoXrKzQVXBeFRUHqattVz+jpbpI/54qJyg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfeduvddggeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesghdtre ertddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehp khhsrdhimheqnecuggftrfgrthhtvghrnhepheeghfdtfeeuffehkefgffduleffjedthf dvjeektdfhhedvlefgtefgvdettdfhnecuvehluhhsthgvrhfuihiivgepudenucfrrghr rghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 11 Jun 2024 07:58:35 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 56602aeb (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Tue, 11 Jun 2024 11:58:26 +0000 (UTC) Date: Tue, 11 Jun 2024 13:58:33 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 13/21] oidset: pass hash algorithm when parsing file Message-ID: <95d9b5fa3e184d10d55971167c55aef36ce31f8f.1718106285.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The `oidset_parse_file_carefully()` function implicitly depends on `the_repository` when parsing object IDs. Fix this by having callers pass in the hash algorithm to use. Signed-off-by: Patrick Steinhardt --- builtin/blame.c | 1 + fsck.c | 3 ++- oidset.c | 8 +++++--- oidset.h | 4 +++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/builtin/blame.c b/builtin/blame.c index de89fff3f8..18f1a3cea0 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -852,6 +852,7 @@ static void build_ignorelist(struct blame_scoreboard *sb, oidset_clear(&sb->ignore_list); else oidset_parse_file_carefully(&sb->ignore_list, i->string, + the_repository->hash_algo, peel_to_commit_oid, sb); } for_each_string_list_item(i, ignore_rev_list) { diff --git a/fsck.c b/fsck.c index 432996cbb6..304f4a17ec 100644 --- a/fsck.c +++ b/fsck.c @@ -205,7 +205,8 @@ void fsck_set_msg_types(struct fsck_options *options, const char *values) if (!strcmp(buf, "skiplist")) { if (equal == len) die("skiplist requires a path"); - oidset_parse_file(&options->skiplist, buf + equal + 1); + oidset_parse_file(&options->skiplist, buf + equal + 1, + the_repository->hash_algo); buf += len + 1; continue; } diff --git a/oidset.c b/oidset.c index 91d1385910..8d36aef8dc 100644 --- a/oidset.c +++ b/oidset.c @@ -48,12 +48,14 @@ void oidset_clear(struct oidset *set) oidset_init(set, 0); } -void oidset_parse_file(struct oidset *set, const char *path) +void oidset_parse_file(struct oidset *set, const char *path, + const struct git_hash_algo *algop) { - oidset_parse_file_carefully(set, path, NULL, NULL); + oidset_parse_file_carefully(set, path, algop, NULL, NULL); } void oidset_parse_file_carefully(struct oidset *set, const char *path, + const struct git_hash_algo *algop, oidset_parse_tweak_fn fn, void *cbdata) { FILE *fp; @@ -79,7 +81,7 @@ void oidset_parse_file_carefully(struct oidset *set, const char *path, if (!sb.len) continue; - if (parse_oid_hex(sb.buf, &oid, &p) || *p != '\0') + if (parse_oid_hex_algop(sb.buf, &oid, &p, algop) || *p != '\0') die("invalid object name: %s", sb.buf); if (fn && fn(&oid, cbdata)) continue; diff --git a/oidset.h b/oidset.h index 262f4256d6..0106b6f278 100644 --- a/oidset.h +++ b/oidset.h @@ -80,7 +80,8 @@ void oidset_clear(struct oidset *set); * are allowed. Leading whitespace and empty or white-space only lines are * ignored. */ -void oidset_parse_file(struct oidset *set, const char *path); +void oidset_parse_file(struct oidset *set, const char *path, + const struct git_hash_algo *algop); /* * Similar to the above, but with a callback which can (1) return non-zero to @@ -89,6 +90,7 @@ void oidset_parse_file(struct oidset *set, const char *path); */ typedef int (*oidset_parse_tweak_fn)(struct object_id *, void *); void oidset_parse_file_carefully(struct oidset *set, const char *path, + const struct git_hash_algo *algop, oidset_parse_tweak_fn fn, void *cbdata); struct oidset_iter {