]> git.ipfire.org Git - thirdparty/git.git/blobdiff - dir.c
The seventh batch
[thirdparty/git.git] / dir.c
diff --git a/dir.c b/dir.c
index 20ebe4cba2687e027765876ddc57b086fa85dd71..2d83f3311a75131a98a22a1d278b433c32ada560 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -100,6 +100,18 @@ int fspathncmp(const char *a, const char *b, size_t count)
        return ignore_case ? strncasecmp(a, b, count) : strncmp(a, b, count);
 }
 
+int paths_collide(const char *a, const char *b)
+{
+       size_t len_a = strlen(a), len_b = strlen(b);
+
+       if (len_a == len_b)
+               return fspatheq(a, b);
+
+       if (len_a < len_b)
+               return is_dir_sep(b[len_a]) && !fspathncmp(a, b, len_a);
+       return is_dir_sep(a[len_b]) && !fspathncmp(a, b, len_b);
+}
+
 unsigned int fspathhash(const char *str)
 {
        return ignore_case ? strihash(str) : strhash(str);