mirror of
https://github.com/git/git
synced 2024-08-27 11:39:22 +00:00
Merge branch 'rs/apply-lose-prefix-length' into maint
Code clean-up. * rs/apply-lose-prefix-length: apply: remove prefix_length member from apply_state
This commit is contained in:
commit
c7759cd60a
12
apply.c
12
apply.c
|
@ -80,7 +80,6 @@ int init_apply_state(struct apply_state *state,
|
||||||
{
|
{
|
||||||
memset(state, 0, sizeof(*state));
|
memset(state, 0, sizeof(*state));
|
||||||
state->prefix = prefix;
|
state->prefix = prefix;
|
||||||
state->prefix_length = state->prefix ? strlen(state->prefix) : 0;
|
|
||||||
state->lock_file = lock_file;
|
state->lock_file = lock_file;
|
||||||
state->newfd = -1;
|
state->newfd = -1;
|
||||||
state->apply = 1;
|
state->apply = 1;
|
||||||
|
@ -787,11 +786,11 @@ static int guess_p_value(struct apply_state *state, const char *nameline)
|
||||||
* Does it begin with "a/$our-prefix" and such? Then this is
|
* Does it begin with "a/$our-prefix" and such? Then this is
|
||||||
* very likely to apply to our directory.
|
* very likely to apply to our directory.
|
||||||
*/
|
*/
|
||||||
if (!strncmp(name, state->prefix, state->prefix_length))
|
if (starts_with(name, state->prefix))
|
||||||
val = count_slashes(state->prefix);
|
val = count_slashes(state->prefix);
|
||||||
else {
|
else {
|
||||||
cp++;
|
cp++;
|
||||||
if (!strncmp(cp, state->prefix, state->prefix_length))
|
if (starts_with(cp, state->prefix))
|
||||||
val = count_slashes(state->prefix) + 1;
|
val = count_slashes(state->prefix) + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2108,10 +2107,9 @@ static int use_patch(struct apply_state *state, struct patch *p)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Paths outside are not touched regardless of "--include" */
|
/* Paths outside are not touched regardless of "--include" */
|
||||||
if (0 < state->prefix_length) {
|
if (state->prefix && *state->prefix) {
|
||||||
int pathlen = strlen(pathname);
|
const char *rest;
|
||||||
if (pathlen <= state->prefix_length ||
|
if (!skip_prefix(pathname, state->prefix, &rest) || !*rest)
|
||||||
memcmp(state->prefix, pathname, state->prefix_length))
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue