From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-b2-smtp.messagingengine.com (fhigh-b2-smtp.messagingengine.com [202.12.124.153]) (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 70FA942A151 for ; Tue, 7 Jul 2026 14:39:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.153 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783435169; cv=none; b=KBos1Teh15CkLAcuXh8olQ2LyimDjTBIOHMPsqsvUSZlZB6YeNZvMqkRzik2i4b09vxKBvb1V6A+HnOL6xr6ZLDgq0Cs4X0gvyPcUX6FH4YXADwoTwczVKrpJWtD8MyOPzTQVi5gvAkSsmANDUGq30/NRNtVgE1MHvKsiFj6Eiw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783435169; c=relaxed/simple; bh=nss+EK5OuuS5g4kS/O6w8XQw/+QVevonoHCjWGRX61s=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=HOvxfUwVtzUpO5NaPU3AWiG+R76RhgQ7XTGifOqJc8L9Lfjy+CjTCZMm9j3Pb6zliYpAxl1uQJvQVeAIC/Qc0x9/6szozpB+8gfCqkTUUP4MCy3TCNoPaRj5BIqhMCZkjSBYayyBsFDiGNqbx1SBwEc/7RiXk7DGdmcSwL53s1M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b=kUQPjGYb; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=YdwgilAA; arc=none smtp.client-ip=202.12.124.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b="kUQPjGYb"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="YdwgilAA" Received: from phl-compute-10.internal (phl-compute-10.internal [10.202.2.50]) by mailfhigh.stl.internal (Postfix) with ESMTP id B92727A002D; Tue, 7 Jul 2026 10:39:26 -0400 (EDT) Received: from phl-frontend-02 ([10.202.2.161]) by phl-compute-10.internal (MEProxy); Tue, 07 Jul 2026 10:39:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :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=1783435166; x=1783521566; bh=yp+/HCblMe L2SVvFJ8pcqfmsWrKUUhNM/mzbf8G4hcA=; b=kUQPjGYbtMUYIvgaC4URvIsJ4g rPGRTz93LFMW4kFXd9U9EovjzqCvVA9ruZV2lCS6S9fjGfelvmc8QXAA8UqAYg1j mlxJ9nHOiITvmFTKaav8jak5ZlzQPokHUgaeqo3Dc/33AZrWMzG0hp10sJzVWKYL LXWm9cF+A26wWQWr0xEoQZhKudYr76G2J7oGvOUv8c5Cr+SP9Llryw7U9r083S4N zoVJPRmgvoFNH7Ai0ScPy2qaM8af+7zsUPGmPwXQwBgVfH0Ijp6QlWhBBBhGeDP/ v8qxCQD1HCvigtAL8NIuxG5Hi8rlbff/NteelcRCQMuoyccNrHf9BAhOS6Rg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1783435166; x=1783521566; bh=yp+/HCblMe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1ghDCDdO5aNWhm+hxJfTEUci5F8Sk0xtl3m/X/FGZ+g X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 7 Jul 2026 10:39:26 -0400 (EDT) From: Junio C Hamano To: Jeff King Cc: git@vger.kernel.org, Patrick Steinhardt , "brian m. carlson" Subject: Re: [PATCH 1/7] hash: use git_hash_init() consistently In-Reply-To: <20260707050141.GA1288294@coredump.intra.peff.net> (Jeff King's message of "Tue, 7 Jul 2026 01:01:41 -0400") References: <20260707045556.GA1288172@coredump.intra.peff.net> <20260707050141.GA1288294@coredump.intra.peff.net> Date: Tue, 07 Jul 2026 07:39:24 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Jeff King writes: > We'd like to add more logic to git_hash_init(), but many callers skip it > and call algop->init_fn() directly. Let's make sure we're consistently > using the wrapper by adding a coccinelle rule. > > Besides the coccinelle file itself, this is a purely mechanical > conversion based on the patch it generates. There should be no bare > init_fn() calls left (except for the one in the wrapper). > > Signed-off-by: Jeff King > --- > It feels like the "expression ALGO" in the rule should be a > "git_hash_algo", but I had trouble getting coccinelle to recognize all > cases when I did that. Probably not worth digging too far into, as > the presence of the git_hash_ctx type means we should never hit any > false positives. Thanks. May conversions do look simple and straight-forward, but some look a bit curious. > diff --git a/object-file.c b/object-file.c > index e3c68cfb66..f292683c2d 100644 > --- a/object-file.c > +++ b/object-file.c > ... > - algo->init_fn(c); > - if (compat && compat_c) > - compat->init_fn(compat_c); > + git_hash_init(c, algo); > + if (compat && compat_c) { > + git_hash_init(compat_c, compat); > + } For example, it is a mystery how Coccinelle decided to add a pair of braces around this single statement. It should be obvious that the corresponding single statement in the original did not need one. > diff --git a/rerere.c b/rerere.c > index 8232542585..2e932439a4 100644 > --- a/rerere.c > +++ b/rerere.c > @@ -438,8 +438,9 @@ static int handle_path(unsigned char *hash, struct rerere_io *io, int marker_siz > struct git_hash_ctx ctx; > struct strbuf buf = STRBUF_INIT, out = STRBUF_INIT; > int has_conflicts = 0; > - if (hash) > - the_hash_algo->init_fn(&ctx); > + if (hash) { > + git_hash_init(&ctx, the_hash_algo); > + } Ditto.