From patchwork Mon May 13 10:23:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13663271 Received: from wfhigh6-smtp.messagingengine.com (wfhigh6-smtp.messagingengine.com [64.147.123.157]) (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 43B12146D76 for ; Mon, 13 May 2024 10:23:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715595801; cv=none; b=ZTjI5pJoXwN/a45LKQF/oLrYE33f1zPTvVlo3tOepdLIPFtgs5zTCnqfviJNrdWLtD2pJzQtx9g1ZZakAyLtFlEZPcCV99q8XBX9jBxpsYC4UvlmiOOGIARODqNIXThDiBb2xnUyTSdhhgI71IHEalYLYMb4fh5CReowHGP8ng0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715595801; c=relaxed/simple; bh=FwWnck4Fe7vbzNybcIjshHM2d2kaUn/5j3dZAATy9EQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CVwQRhsxAtX5L8C+f/3xDffaYJmHYLL5Yx/52/+8n++fVKv2ldYUsUIfNiVBByf41Q3b1q9pb1QM0IcxMxOptM0tvgvT8WqCG4/s+Qzez2nZVQbTbmC7KBw8CObhrJYTthKJMPvwr9SR9gedOWYrRR8YXOOLjdBsZmg4a3y1cis= 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=oSST+2aY; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=OPzs4LB2; arc=none smtp.client-ip=64.147.123.157 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="oSST+2aY"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="OPzs4LB2" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfhigh.west.internal (Postfix) with ESMTP id 90C151800105; Mon, 13 May 2024 06:23:19 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 13 May 2024 06:23:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; 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=fm3; t=1715595799; x=1715682199; bh=UO2dj4aUGU 8J1avARLpaFfR5DNvIAtaUr+SHqxd7Cs8=; b=oSST+2aYhLGr1dMy9qzCyTvflt Wy4lQixEnzN3+Yg6RyKGjesbL9G0s6uT1Dn/QAc4Z9c2vYL592vhjtcLFRVMEivw edDGe9q0Ayusy2y4kT4ghuP9SlkJijBpnE8hUWruVm+Taf3bPqOD+IS3Xj7eFnYJ Ov1PfG8nPaiDf4pIR/364B54pWypbHjKnFG6Q/jNG4TGbxgZhkKaRwq2YlIrxm+A zY7LopMlJXPCfTeNmDUVWiv1caVT3xq5tcg4LwndPYaZs6MCYk0F44IoJ1GtuFHv TtJ5+lYePuzTEY8xRAiyvHo9PexxhXXj8lz4LcuftLpt6u9ly96q2con/SnA== 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-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1715595799; x=1715682199; bh=UO2dj4aUGU8J1avARLpaFfR5DNvI AtaUr+SHqxd7Cs8=; b=OPzs4LB24EU/yT/krosPo7KXWUXe5rmFtGd8XFShMrXe rtyFr42tHjLdfRm3T0hBpMhyIkAb3MIWUeFJi68EMo3vzWLaAsREMXevFbguJv85 9XtuWQ/IlmomAu8PNzj3XUFLp66z+DkdZMBUVkro8TnG+ol3w0znrb5B1f7laGen TlC7qDw4N7YJuhNYFc2Vdo8Rr3OVOjSh7QEmbpw/6RymsyGL/o22X512t9apVyoE VNnl6w2z787NhYI5cLASzeQ1PYOcAJrvfhlD8nUmJjXzmUxvEr/oktwhprRMTPwV UeEYaB+36tMsp6iCfCKY9AdOonGMRUDGnxAdl1OBZQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdeggedgvdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvdenucfhrhhomheprfgrthhr ihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvg hrnhepueektdevtdffveeljeetgfehheeigeekleduvdeffeeghefgledttdehjeelffet necuvehluhhsthgvrhfuihiivgepheenucfrrghrrghmpehmrghilhhfrhhomhepphhsse hpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 13 May 2024 06:23:18 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 21511ac7 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 13 May 2024 10:22:59 +0000 (UTC) Date: Mon, 13 May 2024 12:23:15 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Junio C Hamano , Kyle Lippincott , Eric Sunshine Subject: [PATCH v2 15/21] builtin/config: convert `value_pattern` to a local variable Message-ID: 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 `value_pattern` variable is used by the `format_config()` callback when `CONFIG_FLAGS_FIXED_VALUE` is used. It is only ever set up by its only caller, `collect_config()` and can thus easily be moved into the `collect_config_data` structure. Do so to remove our reliance on global state. Signed-off-by: Patrick Steinhardt --- builtin/config.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/builtin/config.c b/builtin/config.c index 16d92ab176..a17e274ece 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -124,7 +124,6 @@ struct config_display_options { static char *key; static regex_t *key_regexp; -static const char *value_pattern; static regex_t *regexp; static int use_key_regexp; static int do_all; @@ -326,6 +325,7 @@ static int format_config(const struct config_display_options *opts, struct collect_config_data { const struct config_display_options *display_opts; struct strbuf_list *values; + const char *value_pattern; int do_not_match; }; @@ -340,7 +340,7 @@ static int collect_config(const char *key_, const char *value_, return 0; if (use_key_regexp && regexec(key_regexp, key_, 0, NULL, 0)) return 0; - if (fixed_value && strcmp(value_pattern, (value_?value_:""))) + if (fixed_value && strcmp(data->value_pattern, (value_?value_:""))) return 0; if (regexp != NULL && (data->do_not_match ^ !!regexec(regexp, (value_?value_:""), 0, NULL, 0))) @@ -397,7 +397,7 @@ static int get_value(const struct config_location_options *opts, } if (regex_ && (flags & CONFIG_FLAGS_FIXED_VALUE)) - value_pattern = regex_; + data.value_pattern = regex_; else if (regex_) { if (regex_[0] == '!') { data.do_not_match = 1;