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

[PATCH 3/3] config: normalize the path of the system gitconfig

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Jun 22, 2021, 10:46 UTC
Message-ID
<01aa77d9acbbdbaf90937e14f276e981e77568c3.1624358809.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.984.git.1624358809.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

Git for Windows is compiled with a runtime prefix, and that runtime prefix is typically `C:/Program Files/Git/mingw64`. As we want the system gitconfig to live in the sibling directory `etc`, we define the relative path as `../etc/gitconfig`.

However, as reported by Philip Oakley, the output of `git config --show-origin --system -l` looks rather ugly, as it shows the path as `file:C:/Program Files/Git/mingw64/../etc/gitconfig`, i.e. with the `mingw64/../` part.

By normalizing the path, we get a prettier path.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 config.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/config.c b/config.c
index f9c400ad3062..3cd10aeb9028 100644
--- a/config.c
+++ b/config.c
@@ -1833,9 +1833,10 @@ static int git_config_from_blob_ref(config_fn_t fn,
 char *git_system_config(void)
 {
 	char *system_config = xstrdup_or_null(getenv("GIT_CONFIG_SYSTEM"));
-	if (system_config)
-		return system_config;
-	return system_path(ETC_GITCONFIG);
+	if (!system_config)
+		system_config = system_path(ETC_GITCONFIG);
+	normalize_path_copy(system_config, system_config);
+	return system_config;
 }
 
 void git_global_config(char **user_out, char **xdg_out)
-- 
gitgitgadget
Previous: Dennis Ameling via GitGitGadgetNext: Johannes Schindelin via GitGitGadget
Message 3 of 4 in “Move Git for Windows' system config to its top-level directory's etc/”
  1. 0/3 Move Git for Windows' system config to its top-level directory's etc/Johannes Schindelin via GitGitGadget, Jun 22, 2021
  2. 2/3 cmake(windows): set correct path to the system Git configDennis Ameling via GitGitGadget, Jun 22, 2021
  3. 3/3 config: normalize the path of the system gitconfigJohannes Schindelin via GitGitGadget, Jun 22, 2021
  4. 1/3 mingw: move Git for Windows' system config where users expect itJohannes Schindelin via GitGitGadget, Jun 22, 2021

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.