summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2015-09-13 14:18:08 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2015-09-13 14:18:08 -0400
commit9d905541bf372cbb17e82eea6dc9c6ac36ab6ea7 (patch)
tree819019980e7fae5a1c5202d91640f81c74071172
parent5a466befaf03021b5bf8f1c7d34d35c8cd316213 (diff)
downloadlibgit2-9d905541bf372cbb17e82eea6dc9c6ac36ab6ea7.tar.gz
diriter: don't double '/' on posix
The canonical directory path of the root directory of a volume on POSIX already ends in a slash (eg, `/`). This is true only at the 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 d14a7699e..cb11acee3 100644
--- a/src/path.c
+++ b/src/path.c
@@ -1319,7 +1319,11 @@ int git_path_diriter_next(git_path_diriter *diriter)
#endif
git_buf_truncate(&diriter->path, diriter->parent_len);
- git_buf_putc(&diriter->path, '/');
+
+ if (diriter->parent_len > 0 &&
+ diriter->path.ptr[diriter->parent_len-1] != '/')
+ git_buf_putc(&diriter->path, '/');
+
git_buf_put(&diriter->path, filename, filename_len);
if (git_buf_oom(&diriter->path))