File tree Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -31,22 +31,22 @@ static int common_prefix(const char **pathspec)
31
31
if (!slash )
32
32
return 0 ;
33
33
34
+ /*
35
+ * The first 'prefix' characters of 'path' are common leading
36
+ * path components among the pathspecs we have seen so far,
37
+ * including the trailing slash.
38
+ */
34
39
prefix = slash - path + 1 ;
35
40
while ((next = * ++ pathspec ) != NULL ) {
36
- int len = strlen (next );
37
- if (len >= prefix && !memcmp (path , next , prefix ))
41
+ int len , last_matching_slash = -1 ;
42
+ for (len = 0 ; len < prefix && next [len ] == path [len ]; len ++ )
43
+ if (next [len ] == '/' )
44
+ last_matching_slash = len ;
45
+ if (len == prefix )
38
46
continue ;
39
- len = prefix - 1 ;
40
- for (;;) {
41
- if (!len )
42
- return 0 ;
43
- if (next [-- len ] != '/' )
44
- continue ;
45
- if (memcmp (path , next , len + 1 ))
46
- continue ;
47
- prefix = len + 1 ;
48
- break ;
49
- }
47
+ if (last_matching_slash < 0 )
48
+ return 0 ;
49
+ prefix = last_matching_slash + 1 ;
50
50
}
51
51
return prefix ;
52
52
}
You can’t perform that action at this time.
0 commit comments