Commit b8b3f2090ed097020d494dbf50d92a34c669707d

Stefan Sperling 2020-02-29T08:15:55

make got_path_is_root_dir() deal with an arbitrary amount of leading slashes

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/lib/path.c b/lib/path.c
index 01ae02e..be971e6 100644
--- a/lib/path.c
+++ b/lib/path.c
@@ -135,7 +135,9 @@ got_path_skip_common_ancestor(char **child, const char *parent_abspath,
 int
 got_path_is_root_dir(const char *path)
 {
-	return (path[0] == '/' && path[1] == '\0');
+	while (*path == '/')
+		path++;
+	return (*path == '\0');
 }
 
 int