Browse Source

Merge branch 'rs/apply-lose-prefix-length'

Code clean-up.

* rs/apply-lose-prefix-length:
  apply: remove prefix_length member from apply_state
maint
Junio C Hamano 7 years ago
parent
commit
1168df9a9c
  1. 12
      apply.c
  2. 1
      apply.h

12
apply.c

@ -80,7 +80,6 @@ int init_apply_state(struct apply_state *state, @@ -80,7 +80,6 @@ int init_apply_state(struct apply_state *state,
{
memset(state, 0, sizeof(*state));
state->prefix = prefix;
state->prefix_length = state->prefix ? strlen(state->prefix) : 0;
state->lock_file = lock_file;
state->newfd = -1;
state->apply = 1;
@ -786,11 +785,11 @@ static int guess_p_value(struct apply_state *state, const char *nameline) @@ -786,11 +785,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
* 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);
else {
cp++;
if (!strncmp(cp, state->prefix, state->prefix_length))
if (starts_with(cp, state->prefix))
val = count_slashes(state->prefix) + 1;
}
}
@ -2089,10 +2088,9 @@ static int use_patch(struct apply_state *state, struct patch *p) @@ -2089,10 +2088,9 @@ static int use_patch(struct apply_state *state, struct patch *p)
int i;

/* Paths outside are not touched regardless of "--include" */
if (0 < state->prefix_length) {
int pathlen = strlen(pathname);
if (pathlen <= state->prefix_length ||
memcmp(state->prefix, pathname, state->prefix_length))
if (state->prefix && *state->prefix) {
const char *rest;
if (!skip_prefix(pathname, state->prefix, &rest) || !*rest)
return 0;
}


1
apply.h

@ -35,7 +35,6 @@ enum apply_verbosity { @@ -35,7 +35,6 @@ enum apply_verbosity {

struct apply_state {
const char *prefix;
int prefix_length;

/* These are lock_file related */
struct lock_file *lock_file;

Loading…
Cancel
Save