git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 0/4] maintenance: use XDG config if it exists

From
Kristoffer Haugsbakk <code@khaugsbakk.name>
Date
Jan 14, 2024, 21:43 UTC
Message-ID
<cover.1705267839.git.code@khaugsbakk.name>
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

Previous: Eric SunshineNext: Kristoffer Haugsbakk
Message 15 of 33 in “maintenance: use XDG config if it exists”
  1. 0/4 maintenance: use XDG config if it existsKristoffer Haugsbakk, Oct 18, 2023
  2. 1/4 config: format newlinesKristoffer Haugsbakk, Oct 18, 2023
  3. 2/4 config: rename global config functionKristoffer Haugsbakk, Oct 18, 2023
  4. 3/4 config: factor out global config file retrievalKristoffer Haugsbakk, Oct 18, 2023
  5. Patrick SteinhardtOct 23, 2023
  6. Taylor BlauOct 23, 2023
  7. Kristoffer HaugsbakkOct 24, 2023
  8. Patrick SteinhardtOct 25, 2023
  9. Kristoffer HaugsbakkOct 25, 2023
  10. Patrick SteinhardtOct 25, 2023
  11. Junio C HamanoOct 27, 2023
  12. 4/4 maintenance: use XDG config if it existsKristoffer Haugsbakk, Oct 18, 2023
  13. Patrick SteinhardtOct 23, 2023
  14. Eric SunshineOct 23, 2023
  15. 0/4 maintenance: use XDG config if it existsKristoffer Haugsbakk, Jan 14, 2024
  16. 1/4 config: format newlinesKristoffer Haugsbakk, Jan 14, 2024
  17. 2/4 config: rename global config functionKristoffer Haugsbakk, Jan 14, 2024
  18. 3/4 config: factor out global config file retrievalKristoffer Haugsbakk, Jan 14, 2024
  19. Junio C HamanoJan 16, 2024
  20. Kristoffer HaugsbakkJan 16, 2024
  21. Patrick SteinhardtJan 19, 2024
  22. Kristoffer HaugsbakkJan 19, 2024
  23. Patrick SteinhardtJan 19, 2024
  24. Junio C HamanoJan 19, 2024
  25. Junio C HamanoJan 19, 2024
  26. rsbecker@nexbridge.comJan 19, 2024
  27. 4/4 maintenance: use XDG config if it existsKristoffer Haugsbakk, Jan 14, 2024
  28. Junio C HamanoJan 16, 2024
  29. 0/4 maintenance: use XDG config if it existsKristoffer Haugsbakk, Jan 18, 2024
  30. 1/4 config: format newlinesKristoffer Haugsbakk, Jan 18, 2024
  31. 2/4 config: rename global config functionKristoffer Haugsbakk, Jan 18, 2024
  32. 3/4 config: factor out global config file retrievalKristoffer Haugsbakk, Jan 18, 2024
  33. 4/4 maintenance: use XDG config if it existsKristoffer Haugsbakk, Jan 18, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.