Commit 9d905541bf372cbb17e82eea6dc9c6ac36ab6ea7

Edward Thomson 2015-09-13T14:18:08

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/src/path.c b/src/path.c
index d14a769..cb11ace 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))