summaryrefslogtreecommitdiff
path: root/path.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-02-05 14:54:17 -0800
committerJunio C Hamano <gitster@pobox.com>2016-02-05 14:54:17 -0800
commit07be1da216debe1f76cd4d03ac5effcb9e40e6c6 (patch)
tree7642a42d6b7348710a13374c6b6dda1b6a51d225 /path.c
parent081363dde231346c2f051cd7d41622f6fa02e3cb (diff)
parente7d5ce816579723150c341116737fb51d8e33eb3 (diff)
downloadgit-07be1da216debe1f76cd4d03ac5effcb9e40e6c6.tar.gz
Merge branch 'js/dirname-basename' into maint
dirname() emulation has been added, as Msys2 lacks it. * js/dirname-basename: mingw: avoid linking to the C library's isalpha() t0060: loosen overly strict expectations t0060: verify that basename() and dirname() work as expected compat/basename.c: provide a dirname() compatibility function compat/basename: make basename() conform to POSIX Refactor skipping DOS drive prefixes
Diffstat (limited to 'path.c')
-rw-r--r--path.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/path.c b/path.c
index 3cd155e27d..8b7e168129 100644
--- a/path.c
+++ b/path.c
@@ -782,13 +782,10 @@ const char *relative_path(const char *in, const char *prefix,
else if (!prefix_len)
return in;
- if (have_same_root(in, prefix)) {
+ if (have_same_root(in, prefix))
/* bypass dos_drive, for "c:" is identical to "C:" */
- if (has_dos_drive_prefix(in)) {
- i = 2;
- j = 2;
- }
- } else {
+ i = j = has_dos_drive_prefix(in);
+ else {
return in;
}
@@ -943,11 +940,10 @@ const char *remove_leading_path(const char *in, const char *prefix)
int normalize_path_copy_len(char *dst, const char *src, int *prefix_len)
{
char *dst0;
+ int i;
- if (has_dos_drive_prefix(src)) {
+ for (i = has_dos_drive_prefix(src); i > 0; i--)
*dst++ = *src++;
- *dst++ = *src++;
- }
dst0 = dst;
if (is_dir_sep(*src)) {