summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-09-13 13:59:41 -0400
committerEdward Thomson <ethomson@microsoft.com>2015-09-13 13:59:41 -0400
commit5a466befaf03021b5bf8f1c7d34d35c8cd316213 (patch)
treef93c35edb7b54cdf8ee53c8d98fb93d658f1d0b3
parent2cde210d47f94962443cc090896cc1d5ef88452f (diff)
downloadlibgit2-5a466befaf03021b5bf8f1c7d34d35c8cd316213.tar.gz
diriter: don't double '/' on Windows
The canonical directory path of the root directory of a volume on windows already ends in a slash (eg, `c:/`). This is true only at the volume root. Do not add a slash to paths in this case.
-rw-r--r--src/path.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/path.c b/src/path.c
index 9ce5d2978..d14a7699e 100644
--- a/src/path.c
+++ b/src/path.c
@@ -1166,7 +1166,11 @@ static int diriter_update_paths(git_path_diriter *diriter)
diriter->path[path_len-1] = L'\0';
git_buf_truncate(&diriter->path_utf8, diriter->parent_utf8_len);
- git_buf_putc(&diriter->path_utf8, '/');
+
+ if (diriter->parent_utf8_len > 0 &&
+ diriter->path_utf8.ptr[diriter->parent_utf8_len-1] != '/')
+ git_buf_putc(&diriter->path_utf8, '/');
+
git_buf_put_w(&diriter->path_utf8, diriter->current.cFileName, filename_len);
if (git_buf_oom(&diriter->path_utf8))