Skip to content

Commit 5ca6b7b

Browse files
dschogitster
authored andcommitted
config --show-origin: report paths with forward slashes
On Windows, the backslash is the native directory separator, but 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. So let's try to be consistent and use forward slashes in the $HOME part of the paths reported by `git config --show-origin`, too. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 808ecd4 commit 5ca6b7b

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

compat/mingw.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,12 @@ static inline char *mingw_find_last_dir_sep(const char *path)
396396
ret = (char *)path;
397397
return ret;
398398
}
399+
static inline void convert_slashes(char *path)
400+
{
401+
for (; *path; path++)
402+
if (*path == '\\')
403+
*path = '/';
404+
}
399405
#define find_last_dir_sep mingw_find_last_dir_sep
400406
int mingw_offset_1st_component(const char *path);
401407
#define offset_1st_component mingw_offset_1st_component

path.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,9 @@ char *expand_user_path(const char *path)
584584
if (!home)
585585
goto return_null;
586586
strbuf_addstr(&user_path, home);
587+
#ifdef GIT_WINDOWS_NATIVE
588+
convert_slashes(user_path.buf);
589+
#endif
587590
} else {
588591
struct passwd *pw = getpw_str(username, username_len);
589592
if (!pw)

0 commit comments

Comments
 (0)