@@ -80,7 +80,6 @@ int init_apply_state(struct apply_state *state,
80
80
{
81
81
memset (state , 0 , sizeof (* state ));
82
82
state -> prefix = prefix ;
83
- state -> prefix_length = state -> prefix ? strlen (state -> prefix ) : 0 ;
84
83
state -> lock_file = lock_file ;
85
84
state -> newfd = -1 ;
86
85
state -> apply = 1 ;
@@ -787,11 +786,11 @@ static int guess_p_value(struct apply_state *state, const char *nameline)
787
786
* Does it begin with "a/$our-prefix" and such? Then this is
788
787
* very likely to apply to our directory.
789
788
*/
790
- if (! strncmp (name , state -> prefix , state -> prefix_length ))
789
+ if (starts_with (name , state -> prefix ))
791
790
val = count_slashes (state -> prefix );
792
791
else {
793
792
cp ++ ;
794
- if (! strncmp (cp , state -> prefix , state -> prefix_length ))
793
+ if (starts_with (cp , state -> prefix ))
795
794
val = count_slashes (state -> prefix ) + 1 ;
796
795
}
797
796
}
@@ -2108,10 +2107,9 @@ static int use_patch(struct apply_state *state, struct patch *p)
2108
2107
int i ;
2109
2108
2110
2109
/* Paths outside are not touched regardless of "--include" */
2111
- if (0 < state -> prefix_length ) {
2112
- int pathlen = strlen (pathname );
2113
- if (pathlen <= state -> prefix_length ||
2114
- memcmp (state -> prefix , pathname , state -> prefix_length ))
2110
+ if (state -> prefix && * state -> prefix ) {
2111
+ const char * rest ;
2112
+ if (!skip_prefix (pathname , state -> prefix , & rest ) || !* rest )
2115
2113
return 0 ;
2116
2114
}
2117
2115
0 commit comments