Commit 89b6531
committed
path: use forward slashes for XDG config on windows
Windows uses backslashes as directory separators. A previous patch [1]
converted backslashes to forward slashes in the `config --show-origin`
output on Windows.
However, we missed the XDG config path which still uses backslashes. To
reproduce the issue on Windows:
1. Populate `$XDG_CONFIG_HOME/git/config`. For example,
[xdg]
foo = bar
2. Ensure some other file is being sourced for config, e.g. system.
3. Run `git config --list --show-origin`. The XDG path contains
backslashes, while the other paths contain forward slashes:
file:C:/Program Files/Git/etc/gitconfig system.foo=bar
file:"C:\\Users\\delilah/.config/git/config" xdg.foo=bar
file:C:/Users/delilah/.gitconfig home.foo=bar
file:.git/config local.foo=bar
For the same reasons as in [1],
> All supported Windows versions also accept the forward slash in
> most circumstances.
> Our tests expect forward slashes.
> Relative paths are generated by Git using forward slashes.
We should be consistent and use forward slashes in the XDG path as well.
There are several places to insert a call to `convert_slashes(path)`. I
chose `cleanup_path()` because the name suggests some form of
normalisation and it is already called in the relevant code paths.
Discard the constness of `cleanup_path()` to modifying the path in
place. It calls `skip_prefix(..., const char **out)`, which sets `**out`
to some point in the original string. Hence, it seems we can safely cast
`char**` to `const char**`` for this purpose. But please correct me if
I'm wrong!
[1]: https://lore.kernel.org/git/8beb1c208e33e1de8f272caa22fb7a0b662ca4cc.1458730457.git.johannes.schindelin@gmx.de/
Suggested-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Delilah Ashley Wu <delilahwu@microsoft.com>1 parent a483264 commit 89b6531
1 file changed
+7
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
| |||
0 commit comments