config: normalize the path of the system gitconfig

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Jun 22, 2021 at 10:46 UTC e355307692f49f2f02275b083e91532efed9f7c0
1 file changed +4 -3
config.c
+4 -3
@@ -1833,9 +1833,10 @@ static int git_config_from_blob_ref(config_fn_t fn,
1833 char *git_system_config(void)
1834 {
1835 char *system_config = xstrdup_or_null(getenv("GIT_CONFIG_SYSTEM"));
1836 - if (system_config)
1837 - return system_config;
1838 - return system_path(ETC_GITCONFIG);
1836 + if (!system_config)
1837 + system_config = system_path(ETC_GITCONFIG);
1838 + normalize_path_copy(system_config, system_config);
1839 + return system_config;
1840 }
1841
1842 void git_global_config(char **user_out, char **xdg_out)