Skip to content

Commit

Permalink
config: normalize the path of the system gitconfig
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dscho committed Oct 25, 2019
1 parent b1b9387 commit 3a5522c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1657,9 +1657,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;
}

Expand Down

0 comments on commit 3a5522c

Please sign in to comment.