Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
Windows: shorten code by re-using convert_slashes()
author
Johannes Sixt
<j6t@kdbg.org>
Sat, 2 Apr 2016 19:03:14 +0000
(21:03 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Tue, 5 Apr 2016 01:03:02 +0000
(18:03 -0700)
Make a few more spots more readable by using the recently introduced,
Windows-specific helper.
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
abspath.c
patch
|
blob
|
history
compat/mingw.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
8257d3b
)
diff --git
a/abspath.c
b/abspath.c
index 5edb4e78162ca6646ef42ad2c8abc36872cd75a5..2825de85912fc730d9a40fa66f4f83b6250a4171 100644
(file)
--- a/
abspath.c
+++ b/
abspath.c
@@
-167,7
+167,6
@@
const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
strbuf_add(&path, pfx, pfx_len);
strbuf_addstr(&path, arg);
#else
strbuf_add(&path, pfx, pfx_len);
strbuf_addstr(&path, arg);
#else
- char *p;
/* don't add prefix to absolute paths, but still replace '\' by '/' */
strbuf_reset(&path);
if (is_absolute_path(arg))
/* don't add prefix to absolute paths, but still replace '\' by '/' */
strbuf_reset(&path);
if (is_absolute_path(arg))
@@
-175,9
+174,7
@@
const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
else if (pfx_len)
strbuf_add(&path, pfx, pfx_len);
strbuf_addstr(&path, arg);
else if (pfx_len)
strbuf_add(&path, pfx, pfx_len);
strbuf_addstr(&path, arg);
- for (p = path.buf + pfx_len; *p; p++)
- if (*p == '\\')
- *p = '/';
+ convert_slashes(path.buf + pfx_len);
#endif
return path.buf;
}
#endif
return path.buf;
}
diff --git
a/compat/mingw.c
b/compat/mingw.c
index 54c82ecf201dde2c317efe6862173c1b40f2552d..0413d5c3cdd128ca721c75b588dc557bdbb1f949 100644
(file)
--- a/
compat/mingw.c
+++ b/
compat/mingw.c
@@
-763,15
+763,12
@@
struct tm *localtime_r(const time_t *timep, struct tm *result)
char *mingw_getcwd(char *pointer, int len)
{
char *mingw_getcwd(char *pointer, int len)
{
- int i;
wchar_t wpointer[MAX_PATH];
if (!_wgetcwd(wpointer, ARRAY_SIZE(wpointer)))
return NULL;
if (xwcstoutf(pointer, wpointer, len) < 0)
return NULL;
wchar_t wpointer[MAX_PATH];
if (!_wgetcwd(wpointer, ARRAY_SIZE(wpointer)))
return NULL;
if (xwcstoutf(pointer, wpointer, len) < 0)
return NULL;
- for (i = 0; pointer[i]; i++)
- if (pointer[i] == '\\')
- pointer[i] = '/';
+ convert_slashes(pointer);
return pointer;
}
return pointer;
}
@@
-2112,9
+2109,7
@@
static void setup_windows_environment()
* executable (by not mistaking the dir separators
* for escape characters).
*/
* executable (by not mistaking the dir separators
* for escape characters).
*/
- for (; *tmp; tmp++)
- if (*tmp == '\\')
- *tmp = '/';
+ convert_slashes(tmp);
}
/* simulate TERM to enable auto-color (see color.c) */
}
/* simulate TERM to enable auto-color (see color.c) */