From: Junio C Hamano <gitster@pobox.com>
To: Kristoffer Haugsbakk <code@khaugsbakk.name>
Cc: git@vger.kernel.org, ps@pks.im, stolee@gmail.com,
Eric Sunshine <sunshine@sunshineco.com>,
Taylor Blau <me@ttaylorr.com>
Subject: Re: [PATCH v2 4/4] maintenance: use XDG config if it exists
Date: Tue, 16 Jan 2024 13:52:20 -0800 [thread overview]
Message-ID: <xmqq7ck9ymi3.fsf@gitster.g> (raw)
In-Reply-To: <8bd67c5bf01ca10fbf575dfa2cf88f8c88b48276.1705267839.git.code@khaugsbakk.name> (Kristoffer Haugsbakk's message of "Sun, 14 Jan 2024 22:43:19 +0100")
Kristoffer Haugsbakk <code@khaugsbakk.name> writes:
> 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);
OK. We used to ask for both user and xdg and without using xdg at
all, as long as $HOME is set, we used $HOME/.gitconfig even if it
did not exist.
What we want to happen is we pick XDG is XDG exists *and* $HOME/.gitconfig
does not. And that is exactly what git_global_config() gives us.
Nicely done.
> @@ -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);
Ditto.
next prev parent reply other threads:[~2024-01-16 21:52 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-18 20:28 [PATCH v1 0/4] maintenance: use XDG config if it exists Kristoffer Haugsbakk
2023-10-18 20:28 ` [PATCH v1 1/4] config: format newlines Kristoffer Haugsbakk
2023-10-18 20:28 ` [PATCH v1 2/4] config: rename global config function Kristoffer Haugsbakk
2023-10-18 20:28 ` [PATCH v1 3/4] config: factor out global config file retrieval Kristoffer Haugsbakk
2023-10-23 9:58 ` Patrick Steinhardt
2023-10-23 17:40 ` [PATCH v1 3/4] config: factor out global config file retrievalync-mailbox> Taylor Blau
2023-10-24 13:23 ` Kristoffer Haugsbakk
2023-10-25 5:38 ` Patrick Steinhardt
2023-10-25 7:33 ` Kristoffer Haugsbakk
2023-10-25 8:05 ` Patrick Steinhardt
2023-10-27 15:54 ` Junio C Hamano
2023-10-18 20:28 ` [PATCH v1 4/4] maintenance: use XDG config if it exists Kristoffer Haugsbakk
2023-10-23 9:58 ` Patrick Steinhardt
2023-10-23 11:39 ` Eric Sunshine
2024-01-14 21:43 ` [PATCH v2 0/4] " Kristoffer Haugsbakk
2024-01-14 21:43 ` [PATCH v2 1/4] config: format newlines Kristoffer Haugsbakk
2024-01-14 21:43 ` [PATCH v2 2/4] config: rename global config function Kristoffer Haugsbakk
2024-01-14 21:43 ` [PATCH v2 3/4] config: factor out global config file retrieval Kristoffer Haugsbakk
2024-01-16 21:39 ` Junio C Hamano
2024-01-16 21:46 ` Kristoffer Haugsbakk
2024-01-19 6:18 ` Patrick Steinhardt
2024-01-19 7:40 ` Kristoffer Haugsbakk
2024-01-19 7:59 ` Patrick Steinhardt
2024-01-19 23:04 ` Junio C Hamano
2024-01-19 18:36 ` Junio C Hamano
2024-01-19 18:59 ` rsbecker
2024-01-14 21:43 ` [PATCH v2 4/4] maintenance: use XDG config if it exists Kristoffer Haugsbakk
2024-01-16 21:52 ` Junio C Hamano [this message]
2024-01-18 16:12 ` [PATCH v3 0/4] " Kristoffer Haugsbakk
2024-01-18 16:12 ` [PATCH v3 1/4] config: format newlines Kristoffer Haugsbakk
2024-01-18 16:12 ` [PATCH v3 2/4] config: rename global config function Kristoffer Haugsbakk
2024-01-18 16:12 ` [PATCH v3 3/4] config: factor out global config file retrieval Kristoffer Haugsbakk
2024-01-18 16:12 ` [PATCH v3 4/4] maintenance: use XDG config if it exists Kristoffer Haugsbakk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq7ck9ymi3.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=code@khaugsbakk.name \
--cc=git@vger.kernel.org \
--cc=me@ttaylorr.com \
--cc=ps@pks.im \
--cc=stolee@gmail.com \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.