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>
This commit is contained in:
Johannes Schindelin
2019-10-25 01:02:33 +02:00
parent 77eb367dd0
commit 66bbeefd09

View File

@@ -1662,9 +1662,11 @@ static int git_config_from_blob_ref(config_fn_t fn,
const char *git_etc_gitconfig(void)
{
static const char *system_wide;
if (!system_wide)
static char *system_wide;
if (!system_wide) {
system_wide = system_path(ETC_GITCONFIG);
normalize_path_copy(system_wide, system_wide);
}
return system_wide;
}