From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-b5-smtp.messagingengine.com (fhigh-b5-smtp.messagingengine.com [202.12.124.156]) (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 20F482BE024 for ; Thu, 17 Jul 2025 10:50:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.156 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752749422; cv=none; b=BkDWoLmkxvknhez0akWDD8kKWDLWztltWBOxXJs2KAEXAcoPx7uXeu2/X4BLLWxZx/Qjp+gAlfmgM0hV6l6GdmMFeBlqgtoGttv4ZGYvIV/3ucX66GbIb23HNk86yOLjwzd5yupPylwNuBItdPGxfGRX9UURuDfZGXXqjJuXU6Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752749422; c=relaxed/simple; bh=Get17BNZWZM/gu3/E4k2dCCEtci5SEL7NKR5SORB+yA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jc19G1+gUjRhzcXPk34Z/DLkqEfkjIKMlNcF/wOezkjc6InAoEvvt6JFNyiMBcDY85qxRpKHbiY2uzkrmKjsKeMfucrF5nBRpT+dyOmjSmfwOOOL/MlmH+lKkTve51GSV5gt04+nkFx/jPh46Y60V/kO2PwtJDv9yjTMGOWx6HU= 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=wjWvcPUZ; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=a+noz7KV; arc=none smtp.client-ip=202.12.124.156 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="wjWvcPUZ"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="a+noz7KV" Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfhigh.stl.internal (Postfix) with ESMTP id 27D177A0223 for ; Thu, 17 Jul 2025 06:50:18 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Thu, 17 Jul 2025 06:50:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-transfer-encoding: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=fm2; t=1752749418; x=1752835818; bh=i7QVxMZf+6f4W0doryktNx1wyHlryb97N5frStdlg8w=; b= wjWvcPUZx9jNGqsYteRSbyJ53ad2/N84KBRVj9omwdDlkju0uwX3Hkwhy7NjQMde k1EqzC3foGNvONR8j3BM8AyqQOzGhGujK6OQqgYcuCsz4pNncxl334428PGbt6TB Kr5sOMObAXKZfo6nyHFdVE9P17C9Z55N3uXQdPsQ3OdABAtoGOXyOs3LDpAdUlwQ 1+ZisMuToDu0bYW5s8Bw/URIkpfqsc67V+DW2VaovgNOQLUCdJqHxFUqzZi/FgBA h4yGGUHUFf6oOqGzkxRfp1I9roLEWrWI/OpMAUghvVB/uWAdnunkIUyu2yRqi7vu mW1kwoeAafL+1/Ia82HX4g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=1752749418; x= 1752835818; bh=i7QVxMZf+6f4W0doryktNx1wyHlryb97N5frStdlg8w=; b=a +noz7KVOP92gcxlnC1+xY/FSUsEFInhfTEgZwA7XEN61dh5TJKpquikkpT5MGH7l dUcrOwVCCefvfPBNs8WXCwN6SFx6nPum3dIBV9947lhsdI/yr7PZvU9MOuFQry3d AZdldgNa1wXTYb5G+FW9u6V4jTieHWOSo8PaS2F9fnyeBPlAe9CWfZLflMGlBdqC Lb/ZK11xeInlQrDYHwK2AN/M8AGxJlYIdHP3CGFwxIH8UM/hFT/Efdtgk1Z20qW3 HhS9ra+WQ+1al2glCPWVXIweg89ViY/KwwO6aDnA8gKkqFkq1ElbUFJMjj+CM5+0 zdurOibeBn1FChw8wVNDA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdeitdefkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertd ertdejnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhk shdrihhmqeenucggtffrrghtthgvrhhnpeffueeiudejvdekheeuvdekfeffiedvueelte ekudehjeetkeegvddugfdtgfeileenucevlhhushhtvghrufhiiigvpedvnecurfgrrhgr mhepmhgrihhlfhhrohhmpehpshesphhkshdrihhmpdhnsggprhgtphhtthhopedupdhmoh guvgepshhmthhpohhuthdprhgtphhtthhopehgihhtsehvghgvrhdrkhgvrhhnvghlrdho rhhg X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Thu, 17 Jul 2025 06:50:17 -0400 (EDT) Received: by mail (OpenSMTPD) with ESMTPSA id 55d4c612 (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO) for ; Thu, 17 Jul 2025 10:50:16 +0000 (UTC) From: Patrick Steinhardt Date: Thu, 17 Jul 2025 12:49:35 +0200 Subject: [PATCH 15/21] config: drop `git_config_set_in_file_gently()` wrapper Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250717-pks-config-wo-the-repository-v1-15-d888e4a17de1@pks.im> References: <20250717-pks-config-wo-the-repository-v1-0-d888e4a17de1@pks.im> In-Reply-To: <20250717-pks-config-wo-the-repository-v1-0-d888e4a17de1@pks.im> To: git@vger.kernel.org Cc: X-Mailer: b4 0.14.2 In 036876a1067 (config: hide functions using `the_repository` by default, 2024-08-13) we have moved around a bunch of functions in the config subsystem that depend on `the_repository`. Those function have been converted into mere wrappers around their equivalent function that takes in a repository as parameter, and the intent was that we'll eventually remove those wrappers to make the dependency on the global repository variable explicit at the callsite. Follow through with that intent and remove `git_config_set_in_file_gently()`. All callsites are adjusted so that they use `repo_config_set_in_file_gently(the_repository, ...)` instead. While some callsites might already have a repository available, this mechanical conversion is the exact same as the current situation and thus cannot cause any regression. Those sites should eventually be cleaned up in a later patch series. Signed-off-by: Patrick Steinhardt --- builtin/config.c | 14 +++++++------- builtin/submodule--helper.c | 2 +- builtin/worktree.c | 4 ++-- config.h | 10 ---------- sequencer.c | 28 ++++++++++++++-------------- submodule-config.c | 2 +- submodule.c | 2 +- worktree.c | 4 ++-- 8 files changed, 28 insertions(+), 38 deletions(-) diff --git a/builtin/config.c b/builtin/config.c index af5d79eadc0..f7e718c6702 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -970,8 +970,8 @@ static int cmd_config_set(int argc, const char **argv, const char *prefix, argv[0], value, value_pattern, comment, flags); } else { - ret = git_config_set_in_file_gently(location_opts.source.file, - argv[0], comment, value); + ret = repo_config_set_in_file_gently(the_repository, location_opts.source.file, + argv[0], comment, value); if (ret == CONFIG_NOTHING_SET) error(_("cannot overwrite multiple values with a single value\n" " Use a regexp, --add or --replace-all to change %s."), argv[0]); @@ -1014,8 +1014,8 @@ static int cmd_config_unset(int argc, const char **argv, const char *prefix, argv[0], NULL, value_pattern, NULL, flags); else - ret = git_config_set_in_file_gently(location_opts.source.file, argv[0], - NULL, NULL); + ret = repo_config_set_in_file_gently(the_repository, location_opts.source.file, argv[0], + NULL, NULL); location_options_release(&location_opts); return ret; @@ -1296,7 +1296,7 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix) check_write(&location_opts.source); check_argc(argc, 2, 2); value = normalize_value(argv[0], argv[1], display_opts.type, &default_kvi); - ret = git_config_set_in_file_gently(location_opts.source.file, argv[0], comment, value); + ret = repo_config_set_in_file_gently(the_repository, location_opts.source.file, argv[0], comment, value); if (ret == CONFIG_NOTHING_SET) error(_("cannot overwrite multiple values with a single value\n" " Use a regexp, --add or --replace-all to change %s."), argv[0]); @@ -1354,8 +1354,8 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix) argv[0], NULL, argv[1], NULL, flags); else - ret = git_config_set_in_file_gently(location_opts.source.file, - argv[0], NULL, NULL); + ret = repo_config_set_in_file_gently(the_repository, location_opts.source.file, + argv[0], NULL, NULL); } else if (actions == ACTION_UNSET_ALL) { check_write(&location_opts.source); diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 710a2a2004e..28f34f7bc18 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1280,7 +1280,7 @@ static void sync_submodule(const char *path, const char *prefix, submodule_to_gitdir(the_repository, &sb, path); strbuf_addstr(&sb, "/config"); - if (git_config_set_in_file_gently(sb.buf, remote_key, NULL, sub_origin_url)) + if (repo_config_set_in_file_gently(the_repository, sb.buf, remote_key, NULL, sub_origin_url)) die(_("failed to update remote for submodule '%s'"), path); diff --git a/builtin/worktree.c b/builtin/worktree.c index b1306248dec..fd517c82c44 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -384,8 +384,8 @@ static void copy_filtered_worktree_config(const char *worktree_git_dir) error(_("failed to unset '%s' in '%s'"), "core.bare", to_file); if (!git_configset_get(&cs, "core.worktree") && - git_config_set_in_file_gently(to_file, - "core.worktree", NULL, NULL)) + repo_config_set_in_file_gently(the_repository, to_file, + "core.worktree", NULL, NULL)) error(_("failed to unset '%s' in '%s'"), "core.worktree", to_file); diff --git a/config.h b/config.h index 43d06c279e3..4e658e47f0a 100644 --- a/config.h +++ b/config.h @@ -734,16 +734,6 @@ static inline int git_config_get_pathname(const char *key, char **dest) return repo_config_get_pathname(the_repository, key, dest); } -static inline int git_config_set_in_file_gently( - const char *config_filename, - const char *key, - const char *comment, - const char *value) -{ - return repo_config_set_in_file_gently(the_repository, config_filename, - key, comment, value); -} - static inline int git_config_set_multivar_in_file_gently( const char *config_filename, const char *key, const char *value, diff --git a/sequencer.c b/sequencer.c index f8d9bb69df8..8acb699f4f2 100644 --- a/sequencer.c +++ b/sequencer.c @@ -3650,57 +3650,57 @@ static int save_opts(struct replay_opts *opts) int res = 0; if (opts->no_commit) - res |= git_config_set_in_file_gently(opts_file, + res |= repo_config_set_in_file_gently(the_repository, opts_file, "options.no-commit", NULL, "true"); if (opts->edit >= 0) - res |= git_config_set_in_file_gently(opts_file, "options.edit", NULL, + res |= repo_config_set_in_file_gently(the_repository, opts_file, "options.edit", NULL, opts->edit ? "true" : "false"); if (opts->allow_empty) - res |= git_config_set_in_file_gently(opts_file, + res |= repo_config_set_in_file_gently(the_repository, opts_file, "options.allow-empty", NULL, "true"); if (opts->allow_empty_message) - res |= git_config_set_in_file_gently(opts_file, + res |= repo_config_set_in_file_gently(the_repository, opts_file, "options.allow-empty-message", NULL, "true"); if (opts->drop_redundant_commits) - res |= git_config_set_in_file_gently(opts_file, + res |= repo_config_set_in_file_gently(the_repository, opts_file, "options.drop-redundant-commits", NULL, "true"); if (opts->keep_redundant_commits) - res |= git_config_set_in_file_gently(opts_file, + res |= repo_config_set_in_file_gently(the_repository, opts_file, "options.keep-redundant-commits", NULL, "true"); if (opts->signoff) - res |= git_config_set_in_file_gently(opts_file, + res |= repo_config_set_in_file_gently(the_repository, opts_file, "options.signoff", NULL, "true"); if (opts->record_origin) - res |= git_config_set_in_file_gently(opts_file, + res |= repo_config_set_in_file_gently(the_repository, opts_file, "options.record-origin", NULL, "true"); if (opts->allow_ff) - res |= git_config_set_in_file_gently(opts_file, + res |= repo_config_set_in_file_gently(the_repository, opts_file, "options.allow-ff", NULL, "true"); if (opts->mainline) { struct strbuf buf = STRBUF_INIT; strbuf_addf(&buf, "%d", opts->mainline); - res |= git_config_set_in_file_gently(opts_file, + res |= repo_config_set_in_file_gently(the_repository, opts_file, "options.mainline", NULL, buf.buf); strbuf_release(&buf); } if (opts->strategy) - res |= git_config_set_in_file_gently(opts_file, + res |= repo_config_set_in_file_gently(the_repository, opts_file, "options.strategy", NULL, opts->strategy); if (opts->gpg_sign) - res |= git_config_set_in_file_gently(opts_file, + res |= repo_config_set_in_file_gently(the_repository, opts_file, "options.gpg-sign", NULL, opts->gpg_sign); for (size_t i = 0; i < opts->xopts.nr; i++) res |= git_config_set_multivar_in_file_gently(opts_file, "options.strategy-option", opts->xopts.v[i], "^$", NULL, 0); if (opts->allow_rerere_auto) - res |= git_config_set_in_file_gently(opts_file, + res |= repo_config_set_in_file_gently(the_repository, opts_file, "options.allow-rerere-auto", NULL, opts->allow_rerere_auto == RERERE_AUTOUPDATE ? "true" : "false"); if (opts->explicit_cleanup) - res |= git_config_set_in_file_gently(opts_file, + res |= repo_config_set_in_file_gently(the_repository, opts_file, "options.default-msg-cleanup", NULL, describe_cleanup_mode(opts->default_msg_cleanup)); return res; diff --git a/submodule-config.c b/submodule-config.c index 70324da3830..1f19fe20774 100644 --- a/submodule-config.c +++ b/submodule-config.c @@ -983,7 +983,7 @@ int config_set_in_gitmodules_file_gently(const char *key, const char *value) { int ret; - ret = git_config_set_in_file_gently(GITMODULES_FILE, key, NULL, value); + ret = repo_config_set_in_file_gently(the_repository, GITMODULES_FILE, key, NULL, value); if (ret < 0) /* Maybe the user already did that, don't error out here */ warning(_("Could not update .gitmodules entry %s"), key); diff --git a/submodule.c b/submodule.c index f8373a9ea7d..fff3c755703 100644 --- a/submodule.c +++ b/submodule.c @@ -2058,7 +2058,7 @@ void submodule_unset_core_worktree(const struct submodule *sub) submodule_name_to_gitdir(&config_path, the_repository, sub->name); strbuf_addstr(&config_path, "/config"); - if (git_config_set_in_file_gently(config_path.buf, "core.worktree", NULL, NULL)) + if (repo_config_set_in_file_gently(the_repository, config_path.buf, "core.worktree", NULL, NULL)) warning(_("Could not unset core.worktree setting in submodule '%s'"), sub->path); diff --git a/worktree.c b/worktree.c index 981a2713374..a2a5f51f29f 100644 --- a/worktree.c +++ b/worktree.c @@ -991,9 +991,9 @@ int should_prune_worktree(const char *id, struct strbuf *reason, char **wtpath, static int move_config_setting(const char *key, const char *value, const char *from_file, const char *to_file) { - if (git_config_set_in_file_gently(to_file, key, NULL, value)) + if (repo_config_set_in_file_gently(the_repository, to_file, key, NULL, value)) return error(_("unable to set %s in '%s'"), key, to_file); - if (git_config_set_in_file_gently(from_file, key, NULL, NULL)) + if (repo_config_set_in_file_gently(the_repository, from_file, key, NULL, NULL)) return error(_("unable to unset %s in '%s'"), key, from_file); return 0; } -- 2.50.1.465.gcb3da1c9e6.dirty