@@ -80,7 +80,6 @@ int init_apply_state(struct apply_state *state,
8080{
8181 memset (state , 0 , sizeof (* state ));
8282 state -> prefix = prefix ;
83- state -> prefix_length = state -> prefix ? strlen (state -> prefix ) : 0 ;
8483 state -> lock_file = lock_file ;
8584 state -> newfd = -1 ;
8685 state -> apply = 1 ;
@@ -787,11 +786,11 @@ static int guess_p_value(struct apply_state *state, const char *nameline)
787786 * Does it begin with "a/$our-prefix" and such? Then this is
788787 * very likely to apply to our directory.
789788 */
790- if (! strncmp (name , state -> prefix , state -> prefix_length ))
789+ if (starts_with (name , state -> prefix ))
791790 val = count_slashes (state -> prefix );
792791 else {
793792 cp ++ ;
794- if (! strncmp (cp , state -> prefix , state -> prefix_length ))
793+ if (starts_with (cp , state -> prefix ))
795794 val = count_slashes (state -> prefix ) + 1 ;
796795 }
797796 }
@@ -2108,10 +2107,9 @@ static int use_patch(struct apply_state *state, struct patch *p)
21082107 int i ;
21092108
21102109 /* 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 )
21152113 return 0 ;
21162114 }
21172115
0 commit comments