MCPcopy Index your code
hub / github.com/git/git / use_patch

Function use_patch

apply.c:2213–2238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2211}
2212
2213static int use_patch(struct apply_state *state, struct patch *p)
2214{
2215 const char *pathname = p->new_name ? p->new_name : p->old_name;
2216 int i;
2217
2218 /* Paths outside are not touched regardless of "--include" */
2219 if (state->prefix && *state->prefix) {
2220 const char *rest;
2221 if (!skip_prefix(pathname, state->prefix, &rest) || !*rest)
2222 return 0;
2223 }
2224
2225 /* See if it matches any of exclude/include rule */
2226 for (i = 0; i < state->limit_by_name.nr; i++) {
2227 struct string_list_item *it = &state->limit_by_name.items[i];
2228 if (!wildmatch(it->string, pathname, 0))
2229 return (it->util != NULL);
2230 }
2231
2232 /*
2233 * If we had any include, a path that does not match any rule is
2234 * not used. Otherwise, we saw bunch of exclude rules (or none)
2235 * and such a path is used.
2236 */
2237 return !state->has_include;
2238}
2239
2240/*
2241 * Read the patch text in "buffer" that extends for "size" bytes; stop

Callers 2

parse_chunkFunction · 0.85
apply_patchFunction · 0.85

Calls 1

wildmatchFunction · 0.85

Tested by

no test coverage detected