From patchwork Thu Jan 18 16:12:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kristoffer Haugsbakk X-Patchwork-Id: 13523011 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (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 CFF522D63F for ; Thu, 18 Jan 2024 16:13:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.111.4.29 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705594426; cv=none; b=EpQETu97V30hj5WJCwZDWT9iZ2wIfg80UwY4W4b16ASl6zChBI7SjI9Alwhc4UaJJDDWmvYnDI1H1KKHequf7dFU5WQ4JmnxrCJhdrBpB90xscIkEDRynaARt5z/3v6ZP7Bu4eg2nSPdMX1EJZdg9MMGfsVYWvoOmcPJpnGwrBo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705594426; c=relaxed/simple; bh=j61b5x9RQ4liFjnavtOQOkRll34uKeCQ+O6dBUFkoQc=; h=Received:Received:DKIM-Signature:DKIM-Signature:X-ME-Sender: X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; b=Q1JNTTnyPErLoX99LiA2xgPG/kZhY/CzTGr02MeTu9dNwJot4U2ODKTwkyf1zyb7pU2rPd6IhQnOZ5ITFkIHculSnYANnEn22p9VmWKGUTl5wsrBoV5L13TPe4Sh9e1vQKspuNNTZGxdDpzDWTGwFw8RY4o5wKBr5Mu+ZlvtmAo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=khaugsbakk.name; spf=pass smtp.mailfrom=khaugsbakk.name; dkim=pass (2048-bit key) header.d=khaugsbakk.name header.i=@khaugsbakk.name header.b=C9WFemTP; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=t7w0JlUo; arc=none smtp.client-ip=66.111.4.29 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=khaugsbakk.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=khaugsbakk.name Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=khaugsbakk.name header.i=@khaugsbakk.name header.b="C9WFemTP"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="t7w0JlUo" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id CDA515C00D5; Thu, 18 Jan 2024 11:13:43 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 18 Jan 2024 11:13:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=khaugsbakk.name; h=cc:cc:content-transfer-encoding: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=1705594423; x= 1705680823; bh=3PMwYZ3TK+aS0letAdpJMqPmC2YZhQB8Jz2gw+rBO/A=; b=C 9WFemTPfGlkazwS+h4Ud12UKOZo4h6fztq8YahIe+nvwdWuDrzikI8/WkgxPcsBi AXIy1f9deEtDKxOn+xc4xVHkAytpRdoflV8NH4k/f8AYF6AiQA3EhcZlBrk8X3lg 7telRqKKRy0CtqY+kmIpoM3onwi5mbSF4cP7jH8ZZyZghAT+FtGXBce84VIvY50X 1/y6FtbCvJFc/EfbCtKxQNmFhpsvjmFsZlp79kL/p9QCrdGpkT9eQxTZPkIQmunL 28+N50Sl7yCzgB7VThczqRrn+LESemqQYyto8YAi8FoiyIPF+ITQCctWlrcc40/p OnTb6Es+X0z7eFiInZAhQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=1705594423; x= 1705680823; bh=3PMwYZ3TK+aS0letAdpJMqPmC2YZhQB8Jz2gw+rBO/A=; b=t 7w0JlUoSykK+HKrOEs4Cl/gA4UdREXnv2JOG9OAOrIaqKnWrUtK9s+qmeNZ7yDFJ 7UryKnPOgrsac3LBH9CqugVxE7xoB15DTL+kyYPfcGJnDSHCboGl1FaC6/SHe2LD t52bwat1vO16BmfqBT22d3HVKBX2CgKtaTKYWfdMZYxTMaB4Qo8UOnGqmWHoA931 Ev0NQgGsBC8IUe6BPPQnyGDL1LGzUWqpg40Z7XimtYy127AoVrxug1tRaptDVMa5 nMeH5DEi207B92v8AwTZlqhfTRfqwwhHVvVP/FEp4fATVmF/27VKGX5OVhhq/5Tw fg8sIyBw4qDWu3Yp4WyHw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdejkedgiedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfhrihhs thhofhhfvghrucfjrghughhssggrkhhkuceotghouggvsehkhhgruhhgshgsrghkkhdrnh grmhgvqeenucggtffrrghtthgvrhhnpeetudeiheeguddtgfduveekhfevudeiieetjefh ffetiedtgeejieehtdfhjefgteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpegtohguvgeskhhhrghughhssggrkhhkrdhnrghmvg X-ME-Proxy: Feedback-ID: i2671468f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 18 Jan 2024 11:13:42 -0500 (EST) From: Kristoffer Haugsbakk To: git@vger.kernel.org Cc: Kristoffer Haugsbakk , ps@pks.im, stolee@gmail.com, Eric Sunshine , Taylor Blau , Junio C Hamano Subject: [PATCH v3 1/4] config: format newlines Date: Thu, 18 Jan 2024 17:12:49 +0100 Message-ID: <1c92b772ef48a91e76b51fd58d941cfdcad93aec.1705593810.git.code@khaugsbakk.name> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove unneeded newlines according to `clang-format`. Signed-off-by: Kristoffer Haugsbakk --- Notes (series): Honestly the formatter changing these lines over and over again was just annoying. And we're visiting the file anyway. builtin/config.c | 1 - config.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/builtin/config.c b/builtin/config.c index 11a4d4ef141..87d0dc92d99 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -760,7 +760,6 @@ int cmd_config(int argc, const char **argv, const char *prefix) given_config_source.scope = CONFIG_SCOPE_COMMAND; } - if (respect_includes_opt == -1) config_options.respect_includes = !given_config_source.file; else diff --git a/config.c b/config.c index 9ff6ae1cb90..d26e16e3ce3 100644 --- a/config.c +++ b/config.c @@ -95,7 +95,6 @@ static long config_file_ftell(struct config_source *conf) return ftell(conf->u.file); } - static int config_buf_fgetc(struct config_source *conf) { if (conf->u.buf.pos < conf->u.buf.len) @@ -3418,7 +3417,6 @@ int git_config_set_multivar_in_file_gently(const char *config_filename, write_err_out: ret = write_error(get_lock_file_path(&lock)); goto out_free; - } void git_config_set_multivar_in_file(const char *config_filename, From patchwork Thu Jan 18 16:12:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kristoffer Haugsbakk X-Patchwork-Id: 13523012 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (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 2E1D22D796 for ; Thu, 18 Jan 2024 16:13:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.111.4.29 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705594428; cv=none; b=qFOXC2prqyOUnvN82JR45WhlhJItZ4D79WSTz4gLfAWzaHvknambP8FCytNXDJFRWuxWingY/rmNvs7L1+GO2YHQ88AG9iX3/ZOwRKipiAVgii7uhtCbI1MEku8MLXBQZt2SQKVwzfcAt+0eCHDTY7LMaPYthB5XbGhgPI1Oqr8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705594428; c=relaxed/simple; bh=79cOdscSHblUIPlzLaTQc17ai/urYL0tuT2ZIHnkCXg=; h=Received:Received:DKIM-Signature:DKIM-Signature:X-ME-Sender: X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; b=J/5DYVf/XkNVlFHE6RjpxaBlBWrjrqSOJth8q3bsT0fiY9OwKhmio/ghFsM9Zq2zTX1/LrYx6nQmvrmODZAjAVSRynY0LxI6DO0bPOj2hdV1Yw1ARR3WTb2urYYTmv68fYsARs9QhlQy6QOixcgDA14sIQ2s9o+P1RDbWnOnrkg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=khaugsbakk.name; spf=pass smtp.mailfrom=khaugsbakk.name; dkim=pass (2048-bit key) header.d=khaugsbakk.name header.i=@khaugsbakk.name header.b=i1JSoFTX; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=p8FwPJcM; arc=none smtp.client-ip=66.111.4.29 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=khaugsbakk.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=khaugsbakk.name Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=khaugsbakk.name header.i=@khaugsbakk.name header.b="i1JSoFTX"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="p8FwPJcM" Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 14BD45C00DE; Thu, 18 Jan 2024 11:13:46 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 18 Jan 2024 11:13:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=khaugsbakk.name; h=cc:cc:content-transfer-encoding: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=1705594426; x= 1705680826; bh=TLtZL3NgybPv6rdIHhR1knaHaa+Qi6aI6gTVnGlZrQM=; b=i 1JSoFTXI3lSdVW3KOJ6ks1/DH15waI3MhPgr26a9XGyYcyoY9wrvFMS60UaGgT/l XhTs2zA/YoVD8kNtWWmfsx+jmPX55CdwWqoUMQlPJ0dAnlEBfZWhZa6UEoOE2uqV fhVR+LXKxqngOjJkqbnu4NBdsP3actaZipZviYt4z/AEzK4kfMpQzc77XEjFlubM 8kcizAnwI8oVBy16wCQYdSAEIvAEa0de70OVu3Xxrqkn0aZuZbevVkWpR4gS4mIL LeRZgSlf8iCaQvHpdJqy95kf2sBowcPlrE/ZGwclux/j9Pf98aTu99PFziPpw5VG sVSXZtyio8KXS3abAwCug== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=1705594426; x= 1705680826; bh=TLtZL3NgybPv6rdIHhR1knaHaa+Qi6aI6gTVnGlZrQM=; b=p 8FwPJcMXrOn5yBSCvHi5j7vYYwfFam9LPuk35CH763KBbkNZmsW/4Gw0yjASaBK5 Fw5PthyqpnAUKvEYofKfPCexotIzFtjVt6UZeg7iK/RB1xtoubLQUzoh68O0luUJ 2ZJXCvpgWHbeD+mOg+MkdM71fpafDSgATGutExWEMtTf2Sg+o9j7z1TLZ6oNYRjA GTceBECL4ZT2HSx0m7WYqkqy5BtoItqkaK4Vey4JUhHbcML/y3l0Wcc9cO9Mq6Ya A73J2rCE9rbupFgFwbbgMpLoLF0UAnAQY8pG2F+m9pkAY5KxjbBTHomLGo2vE8JO CC3lUeGoE8QZ+JKsi7cyw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdejkedgieduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfhrihhs thhofhhfvghrucfjrghughhssggrkhhkuceotghouggvsehkhhgruhhgshgsrghkkhdrnh grmhgvqeenucggtffrrghtthgvrhhnpeetudeiheeguddtgfduveekhfevudeiieetjefh ffetiedtgeejieehtdfhjefgteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpegtohguvgeskhhhrghughhssggrkhhkrdhnrghmvg X-ME-Proxy: Feedback-ID: i2671468f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 18 Jan 2024 11:13:43 -0500 (EST) From: Kristoffer Haugsbakk To: git@vger.kernel.org Cc: Kristoffer Haugsbakk , ps@pks.im, stolee@gmail.com, Eric Sunshine , Taylor Blau , Junio C Hamano Subject: [PATCH v3 2/4] config: rename global config function Date: Thu, 18 Jan 2024 17:12:50 +0100 Message-ID: <269490794bc17053c151d6773c7157cfb30e35bb.1705593810.git.code@khaugsbakk.name> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Rename this function to a more descriptive name since we want to use the existing name for a new function. Signed-off-by: Kristoffer Haugsbakk --- builtin/config.c | 2 +- builtin/gc.c | 4 ++-- builtin/var.c | 2 +- config.c | 4 ++-- config.h | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/builtin/config.c b/builtin/config.c index 87d0dc92d99..6fff2655816 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -710,7 +710,7 @@ int cmd_config(int argc, const char **argv, const char *prefix) if (use_global_config) { char *user_config, *xdg_config; - git_global_config(&user_config, &xdg_config); + git_global_config_paths(&user_config, &xdg_config); if (!user_config) /* * It is unknown if HOME/.gitconfig exists, so diff --git a/builtin/gc.c b/builtin/gc.c index 7c11d5ebef0..c078751824c 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -1546,7 +1546,7 @@ static int maintenance_register(int argc, const char **argv, const char *prefix) char *user_config = NULL, *xdg_config = NULL; if (!config_file) { - git_global_config(&user_config, &xdg_config); + git_global_config_paths(&user_config, &xdg_config); config_file = user_config; if (!user_config) die(_("$HOME not set")); @@ -1614,7 +1614,7 @@ static int maintenance_unregister(int argc, const char **argv, const char *prefi int rc; char *user_config = NULL, *xdg_config = NULL; if (!config_file) { - git_global_config(&user_config, &xdg_config); + git_global_config_paths(&user_config, &xdg_config); config_file = user_config; if (!user_config) die(_("$HOME not set")); diff --git a/builtin/var.c b/builtin/var.c index 8cf7dd9e2e5..cf5567208a2 100644 --- a/builtin/var.c +++ b/builtin/var.c @@ -90,7 +90,7 @@ static char *git_config_val_global(int ident_flag UNUSED) char *user, *xdg; size_t unused; - git_global_config(&user, &xdg); + git_global_config_paths(&user, &xdg); if (xdg && *xdg) { normalize_path_copy(xdg, xdg); strbuf_addf(&buf, "%s\n", xdg); diff --git a/config.c b/config.c index d26e16e3ce3..ebc6a57e1c3 100644 --- a/config.c +++ b/config.c @@ -1987,7 +1987,7 @@ char *git_system_config(void) return system_config; } -void git_global_config(char **user_out, char **xdg_out) +void git_global_config_paths(char **user_out, char **xdg_out) { char *user_config = xstrdup_or_null(getenv("GIT_CONFIG_GLOBAL")); char *xdg_config = NULL; @@ -2040,7 +2040,7 @@ static int do_git_config_sequence(const struct config_options *opts, data, CONFIG_SCOPE_SYSTEM, NULL); - git_global_config(&user_config, &xdg_config); + git_global_config_paths(&user_config, &xdg_config); if (xdg_config && !access_or_die(xdg_config, R_OK, ACCESS_EACCES_OK)) ret += git_config_from_file_with_options(fn, xdg_config, data, diff --git a/config.h b/config.h index 14f881ecfaf..e5e523553cc 100644 --- a/config.h +++ b/config.h @@ -382,7 +382,7 @@ int config_error_nonbool(const char *); #endif char *git_system_config(void); -void git_global_config(char **user, char **xdg); +void git_global_config_paths(char **user, char **xdg); int git_config_parse_parameter(const char *, config_fn_t fn, void *data); From patchwork Thu Jan 18 16:12:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kristoffer Haugsbakk X-Patchwork-Id: 13523013 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (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 984172D7B2 for ; Thu, 18 Jan 2024 16:13:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.111.4.29 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705594431; cv=none; b=RaW02pHQFqu4R+h6PeGlDRTVnnyHkZpBrCjov7r1P61O0xFVypT5FS7T+rX4sadu/1yIhkIWeNk9ZdGg4PPna3GqYDfJ3aYvtJ7Co4fvo2c3FZHp5GV47os5ft5hK1Yd6pz739aCxT3KdcptfwdNmywuQ6McYEocuDZnJk5ZiLA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705594431; c=relaxed/simple; bh=If5MDstJm6UXUQVFy+yGlRKP6w/PB5yaW4LYC51sIyo=; h=Received:Received:DKIM-Signature:DKIM-Signature:X-ME-Sender: X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Type:Content-Transfer-Encoding; b=Fl+WTeh6pDueebOKer6ZpQWOErSckxOjo2U+aLBjWKv8d0YyuWQ+WjdGoTwGxZ/DF8sCNRTlb25SMyAyqGkFXCBSwuX3+AaMdrX1VvLYadhaM/7WmbYYPrX70nHFPtzGEvPdKmNgnYNNwHNXUPKzA1eL7sm8Kek2CAqwBp626YA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=khaugsbakk.name; spf=pass smtp.mailfrom=khaugsbakk.name; dkim=pass (2048-bit key) header.d=khaugsbakk.name header.i=@khaugsbakk.name header.b=Y9D8NRcw; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=MYL/tcWO; arc=none smtp.client-ip=66.111.4.29 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=khaugsbakk.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=khaugsbakk.name Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=khaugsbakk.name header.i=@khaugsbakk.name header.b="Y9D8NRcw"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="MYL/tcWO" Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailout.nyi.internal (Postfix) with ESMTP id 7FCBD5C00D7; Thu, 18 Jan 2024 11:13:48 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Thu, 18 Jan 2024 11:13:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=khaugsbakk.name; 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=1705594428; x=1705680828; bh=2OghQhbmWpHOC/sVwSElZqCL2q8M21Kb +JxGTfqgIMk=; b=Y9D8NRcwm6ZSgew1CoZldK+qsjPrBc1CxcmEwWGN2mcx1Zbi q/mdz/AL18b1X0EQoBvHGsVtPP9CMJq6aqcCIrOc1UDKW/mr+Riq+cTEVE0Dj8XZ SMPFvAxIVdQq/geVWIRmt9fGx+voKmTQgzW9KYLfhvFdmO68pzy+jf+p6piSoUak vi2dhcerupPFjoHaeXyq91tuoHHLuDt3T+zW1W5FnzHBUBjXjUloA2YIhqdVujMx CTrLPeXS5IP5J39F6sdW9O3bo3ZZJOh1BeCFDcfCXsEHhh5jfZEtQKSlqIFJeolw lgNsQ9pR875BOy/8WTF8Q7w5V0NZv+vcUQeXQA== 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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1705594428; x= 1705680828; bh=2OghQhbmWpHOC/sVwSElZqCL2q8M21Kb+JxGTfqgIMk=; b=M YL/tcWO5seKjuVYVjrHoIhRPL37xJXNJUbNKfnKooSGKepnAkK7WpYbrPqtQVuKp ZeujyfehgU3I6nfIW548550V6T00++amDOkcZo8xSaNBKLrNpWwL3kIoK+xu1wf2 ySYyAT9861Z3/7Y7Rp2++f64VSyvZ9AkUL5iEWsdhKXoHrODz4z2STNf4CvA7dbS EN2OafUqawXmiB20exa91VhpaWFhXkq1GGrtRE9Y5r+EBtnrbA6DaXp43cnSR5sy zDzjR/mG32vS1SvvIjszh5Dz7vznJw2golDnmHzSxozUFs9URyicZNfcmnAop1Jo yu34QVpaH6GlWXMYHQGtg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdejkedgieduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpefmrhhi shhtohhffhgvrhcujfgruhhgshgsrghkkhcuoegtohguvgeskhhhrghughhssggrkhhkrd hnrghmvgeqnecuggftrfgrthhtvghrnhepueeiueffuefftefhhfefleelhfeuheettedt heevgeejteehgfevffeugffglefhnecuffhomhgrihhnpehkvghrnhgvlhdrohhrghenuc evlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegtohguvges khhhrghughhssggrkhhkrdhnrghmvg X-ME-Proxy: Feedback-ID: i2671468f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 18 Jan 2024 11:13:46 -0500 (EST) From: Kristoffer Haugsbakk To: git@vger.kernel.org Cc: Kristoffer Haugsbakk , ps@pks.im, stolee@gmail.com, Eric Sunshine , Taylor Blau , Junio C Hamano Subject: [PATCH v3 3/4] config: factor out global config file retrieval Date: Thu, 18 Jan 2024 17:12:51 +0100 Message-ID: <0643a85892cf8a7732593646f1e8a4d0e37d38b7.1705593810.git.code@khaugsbakk.name> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Factor out code that retrieves the global config file so that we can use it in `gc.c` as well. Use the old name from the previous commit since this function acts functionally the same as `git_system_config` but for “global”. Signed-off-by: Kristoffer Haugsbakk --- Notes (series): v3: • Remove doc on `git_global_config` • https://lore.kernel.org/git/c87b3d93-74db-4377-a57c-80f766d46e7f@app.fastmail.com/ v2: • Don’t die; return `NULL` builtin/config.c | 25 +++---------------------- config.c | 20 ++++++++++++++++++++ config.h | 1 + 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/builtin/config.c b/builtin/config.c index 6fff2655816..08fe36d4997 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -708,30 +708,11 @@ int cmd_config(int argc, const char **argv, const char *prefix) } if (use_global_config) { - char *user_config, *xdg_config; - - git_global_config_paths(&user_config, &xdg_config); - if (!user_config) - /* - * It is unknown if HOME/.gitconfig exists, so - * we do not know if we should write to XDG - * location; error out even if XDG_CONFIG_HOME - * is set and points at a sane location. - */ + given_config_source.file = git_global_config(); + if (!given_config_source.file) die(_("$HOME not set")); - given_config_source.scope = CONFIG_SCOPE_GLOBAL; - - if (access_or_warn(user_config, R_OK, 0) && - xdg_config && !access_or_warn(xdg_config, R_OK, 0)) { - given_config_source.file = xdg_config; - free(user_config); - } else { - given_config_source.file = user_config; - free(xdg_config); - } - } - else if (use_system_config) { + } else if (use_system_config) { given_config_source.file = git_system_config(); given_config_source.scope = CONFIG_SCOPE_SYSTEM; } else if (use_local_config) { diff --git a/config.c b/config.c index ebc6a57e1c3..3cfeb3d8bd9 100644 --- a/config.c +++ b/config.c @@ -1987,6 +1987,26 @@ char *git_system_config(void) return system_config; } +char *git_global_config(void) +{ + char *user_config, *xdg_config; + + git_global_config_paths(&user_config, &xdg_config); + if (!user_config) { + free(xdg_config); + return NULL; + } + + if (access_or_warn(user_config, R_OK, 0) && xdg_config && + !access_or_warn(xdg_config, R_OK, 0)) { + free(user_config); + return xdg_config; + } else { + free(xdg_config); + return user_config; + } +} + void git_global_config_paths(char **user_out, char **xdg_out) { char *user_config = xstrdup_or_null(getenv("GIT_CONFIG_GLOBAL")); diff --git a/config.h b/config.h index e5e523553cc..5dba984f770 100644 --- a/config.h +++ b/config.h @@ -382,6 +382,7 @@ int config_error_nonbool(const char *); #endif char *git_system_config(void); +char *git_global_config(void); void git_global_config_paths(char **user, char **xdg); int git_config_parse_parameter(const char *, config_fn_t fn, void *data); From patchwork Thu Jan 18 16:12:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kristoffer Haugsbakk X-Patchwork-Id: 13523014 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (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 912C52DF65 for ; Thu, 18 Jan 2024 16:13:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.111.4.29 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705594433; cv=none; b=IUrlW9P4Q3IH9+2Iw/WjAtrHaA9wDQqdn8BnngoHjUwMi1E5VhUCapeEKwModwqm3ghgXOvBtuwUPO7EVWofeTUpKkjiARGnEqqdIh9SucB5PEF3ZIVWH/IvZ3bwnvOJO86u8XCMPOfgdFXO3CCjpMaL0hGMoTxgBGOGI3zRA/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705594433; c=relaxed/simple; bh=cpL6lIRIMWPvwhiVkeP7FuNVvovLlGwbSB80JcUDnug=; h=Received:Received:DKIM-Signature:DKIM-Signature:X-ME-Sender: X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Type:Content-Transfer-Encoding; b=NC+o4jYAcLujf+lDAztR+VVJh5lylPUTtsWnI1aveKneKlioArcJWPcSS0El4U2DAJatCL7Ey3daOr7o8JmpL8L9mKu9lhGXwIiwyiXt0EjORbj5qy/T04Prq4lCb2cqAzWoW3CjYSyWLOD5EAn/LGyJ1/N7aKrheW0OYv5zr1E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=khaugsbakk.name; spf=pass smtp.mailfrom=khaugsbakk.name; dkim=pass (2048-bit key) header.d=khaugsbakk.name header.i=@khaugsbakk.name header.b=N+H4OpMN; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=JsbYyC+i; arc=none smtp.client-ip=66.111.4.29 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=khaugsbakk.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=khaugsbakk.name Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=khaugsbakk.name header.i=@khaugsbakk.name header.b="N+H4OpMN"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="JsbYyC+i" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 9CFC25C00DE; Thu, 18 Jan 2024 11:13:50 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 18 Jan 2024 11:13:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=khaugsbakk.name; 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=1705594430; x=1705680830; bh=DW7CRPU9dPo0SDRpw3mxElfp0Xq0I0hG ctA/vo834Tk=; b=N+H4OpMNLa0cZ9Z4jPgMJT38LDe1AAi7ryioXCeu1w6RAVl5 ZqrmDFoM2oMHGUxuqrqRvaqOYtwHpfZnbNrQY6L4MzRfmumJ57zbtURg1ARcfcwZ pJ7w/nhThyWMcl3pmC15ZRQwKU9CNSadjNAnDx626HUHPqWaIciOxynXbGOgbZQg E+ux0Jk9byTFyIhJAn2KZe7UgMXQB4GyK/NtsjhrFRaymWEsOqey8jH2Ga2NqhjU hsguORPiL6vQet5FFe3RfIAKG9DN6sUsuOxqGKCgTte/rT7QCNP6KNRy6VljCq2C XOA5igEmt1A7C1YVEy6WWhj5+FYjsRFImeFBTw== 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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1705594430; x= 1705680830; bh=DW7CRPU9dPo0SDRpw3mxElfp0Xq0I0hGctA/vo834Tk=; b=J sbYyC+itxEJp3aUGPdLO2Qb7ACrfyDDXoSKAk0KP9egD83ILjZmKgfe9OG3SHysd cAhEDNMflHj3nSZ0+1iXQoU/+mN23B9Uvc4654B82reViNodJ33e9TZyvtD6ab/D W2T67WlUImJmxXYEFsyUGjHDm4Ku+8LQvNGOfhUeAOBxjH2kW2MZknl5uUYUCstq iUjsO2B4roKYHiaQiG0vPzxLzJEy0sSwQchYJdnxWEBuikkz+/FQEjjXPcYV8NEN EHkPIAh4YobRdOGdGAdB91RrMzoZR7s8C7tsMFiZEHKV7eP6Yllnu8C2J+BIX26A udAIVCQlDGOunAeNTwvwg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdejkedgieduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpefmrhhi shhtohhffhgvrhcujfgruhhgshgsrghkkhcuoegtohguvgeskhhhrghughhssggrkhhkrd hnrghmvgeqnecuggftrfgrthhtvghrnhepvefgleevieekgeejieekueevhfelieduvdel geefkeejtdekvedttefgffevtedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomheptghouggvsehkhhgruhhgshgsrghkkhdrnhgrmhgv X-ME-Proxy: Feedback-ID: i2671468f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 18 Jan 2024 11:13:48 -0500 (EST) From: Kristoffer Haugsbakk To: git@vger.kernel.org Cc: Kristoffer Haugsbakk , ps@pks.im, stolee@gmail.com, Eric Sunshine , Taylor Blau , Junio C Hamano Subject: [PATCH v3 4/4] maintenance: use XDG config if it exists Date: Thu, 18 Jan 2024 17:12:52 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 `git maintenance register` registers the repository in the user's global config. `$XDG_CONFIG_HOME/git/config` is supposed to be used if `~/.gitconfig` does not exist. However, this command creates a `~/.gitconfig` file and writes to that one even though the XDG variant exists. This used to work correctly until 50a044f1e4 (gc: replace config subprocesses with API calls, 2022-09-27), when the command started calling the config API instead of git-config(1). Also change `unregister` accordingly. Signed-off-by: Kristoffer Haugsbakk --- Notes (series): v2: • Add `unregister` tests • Use subshell when exporting an env. variable • Style in tests • Free variables properly builtin/gc.c | 27 ++++++++++++------------- t/t7900-maintenance.sh | 45 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 14 deletions(-) diff --git a/builtin/gc.c b/builtin/gc.c index c078751824c..cb80ced6cb5 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -1543,19 +1543,18 @@ static int maintenance_register(int argc, const char **argv, const char *prefix) if (!found) { int rc; - char *user_config = NULL, *xdg_config = NULL; + char *global_config_file = NULL; if (!config_file) { - git_global_config_paths(&user_config, &xdg_config); - config_file = user_config; - if (!user_config) - die(_("$HOME not set")); + global_config_file = git_global_config(); + config_file = global_config_file; } + if (!config_file) + die(_("$HOME not set")); rc = git_config_set_multivar_in_file_gently( config_file, "maintenance.repo", maintpath, CONFIG_REGEX_NONE, 0); - free(user_config); - free(xdg_config); + free(global_config_file); if (rc) die(_("unable to add '%s' value of '%s'"), @@ -1612,18 +1611,18 @@ static int maintenance_unregister(int argc, const char **argv, const char *prefi if (found) { int rc; - char *user_config = NULL, *xdg_config = NULL; + char *global_config_file = NULL; + if (!config_file) { - git_global_config_paths(&user_config, &xdg_config); - config_file = user_config; - if (!user_config) - die(_("$HOME not set")); + global_config_file = git_global_config(); + config_file = global_config_file; } + if (!config_file) + die(_("$HOME not set")); rc = git_config_set_multivar_in_file_gently( config_file, key, NULL, maintpath, CONFIG_FLAGS_MULTI_REPLACE | CONFIG_FLAGS_FIXED_VALUE); - free(user_config); - free(xdg_config); + free(global_config_file); if (rc && (!force || rc == CONFIG_NOTHING_SET)) diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh index 00d29871e65..0943dfa18a3 100755 --- a/t/t7900-maintenance.sh +++ b/t/t7900-maintenance.sh @@ -67,6 +67,51 @@ test_expect_success 'maintenance.auto config option' ' test_subcommand ! git maintenance run --auto --quiet $XDG_CONFIG_HOME/git/config && + git maintenance register && + git config --file=$XDG_CONFIG_HOME/git/config --get maintenance.repo >actual && + pwd >expect && + test_cmp expect actual + ) +' + +test_expect_success 'register does not need XDG_CONFIG_HOME config to exist' ' + test_when_finished git maintenance unregister && + test_path_is_missing $XDG_CONFIG_HOME/git/config && + git maintenance register && + git config --global --get maintenance.repo >actual && + pwd >expect && + test_cmp expect actual +' + +test_expect_success 'unregister uses XDG_CONFIG_HOME config if it exists' ' + test_when_finished rm -r .config/git/config && + ( + XDG_CONFIG_HOME=.config && + export XDG_CONFIG_HOME && + mkdir -p $XDG_CONFIG_HOME/git && + >$XDG_CONFIG_HOME/git/config && + git maintenance register && + git maintenance unregister && + test_must_fail git config --file=$XDG_CONFIG_HOME/git/config --get maintenance.repo >actual && + test_must_be_empty actual + ) +' + +test_expect_success 'unregister does not need XDG_CONFIG_HOME config to exist' ' + test_path_is_missing $XDG_CONFIG_HOME/git/config && + git maintenance register && + git maintenance unregister && + test_must_fail git config --global --get maintenance.repo >actual && + test_must_be_empty actual +' + test_expect_success 'maintenance..enabled' ' git config maintenance.gc.enabled false && git config maintenance.commit-graph.enabled true &&