From: Kristoffer Haugsbakk <code@khaugsbakk.name>
To: git@vger.kernel.org
Cc: Kristoffer Haugsbakk <code@khaugsbakk.name>,
ps@pks.im, stolee@gmail.com,
Eric Sunshine <sunshine@sunshineco.com>,
Taylor Blau <me@ttaylorr.com>
Subject: [PATCH v2 0/4] maintenance: use XDG config if it exists
Date: Sun, 14 Jan 2024 22:43:15 +0100 [thread overview]
Message-ID: <cover.1705267839.git.code@khaugsbakk.name> (raw)
In-Reply-To: <cover.1697660181.git.code@khaugsbakk.name>
I use the conventional XDG config path for the global configuration. This
path is always used except for `git maintenance register` and
`unregister`.
§ Changes since v1
• Free `config_file`
• https://lore.kernel.org/git/ZTZDsIcrB0zwHlFR@tanuki/
• Return `NULL` instead of dying
• https://lore.kernel.org/git/ZTZDqToqcsDiS5AP@tanuki/
• Tests
• Test unregister
• Use subshells
• Style
§ Patches
• 1–3: Preparatory
• 4: The desired change
§ CC
• Patrick Steinhardt: `config` changes; v1 feedback
• Derrick Stolee: `maintenance` changes
• Eric Sunshine: v1 feedback
• Taylor Blau: v1 feedback
Kristoffer Haugsbakk (4):
config: format newlines
config: rename global config function
config: factor out global config file retrieval
maintenance: use XDG config if it exists
builtin/config.c | 26 +++---------------------
builtin/gc.c | 27 ++++++++++++-------------
builtin/var.c | 2 +-
config.c | 26 ++++++++++++++++++++----
config.h | 6 +++++-
t/t7900-maintenance.sh | 45 ++++++++++++++++++++++++++++++++++++++++++
6 files changed, 89 insertions(+), 43 deletions(-)
Range-diff against v1:
1: 39934cb7e50 = 1: d5f6c8d62ec config: format newlines
2: 48a5357f97c = 2: cbc5fde0094 config: rename global config function
3: 147c767443c ! 3: 32e5ec7d866 config: factor out global config file retrieval
@@ Commit message
Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
+
+ ## Notes (series) ##
+ v2:
+ • Don’t die; return `NULL`
+
## builtin/config.c ##
@@ builtin/config.c: int cmd_config(int argc, const char **argv, const char *prefix)
}
@@ builtin/config.c: int cmd_config(int argc, const char **argv, const char *prefix
- * location; error out even if XDG_CONFIG_HOME
- * is set and points at a sane location.
- */
-- die(_("$HOME not set"));
--
+ 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) &&
@@ config.c: char *git_system_config(void)
+ 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.
-+ */
-+ die(_("$HOME not set"));
++ 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)) {
@@ config.h: int config_error_nonbool(const char *);
#endif
char *git_system_config(void);
++/**
++ * Returns `NULL` if is uncertain whether or not `HOME/.gitconfig` exists.
++ */
+char *git_global_config(void);
void git_global_config_paths(char **user, char **xdg);
4: 1e2376a4b99 < -: ----------- maintenance: use XDG config if it exists
-: ----------- > 4: 8bd67c5bf01 maintenance: use XDG config if it exists
--
2.43.0
next prev parent reply other threads:[~2024-01-14 21:44 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 ` Kristoffer Haugsbakk [this message]
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
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1705267839.git.code@khaugsbakk.name \
--to=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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).