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

Function simplify_away

dir.c:2223–2251  ·  view source on GitHub ↗

* This is an inexact early pruning of any recursive directory * reading - if the path cannot possibly be in the pathspec, * return true, and we'll skip it early. */

Source from the content-addressed store, hash-verified

2221 * return true, and we'll skip it early.
2222 */
2223static int simplify_away(const char *path, int pathlen,
2224 const struct pathspec *pathspec)
2225{
2226 int i;
2227
2228 if (!pathspec || !pathspec->nr)
2229 return 0;
2230
2231 GUARD_PATHSPEC(pathspec,
2232 PATHSPEC_FROMTOP |
2233 PATHSPEC_MAXDEPTH |
2234 PATHSPEC_LITERAL |
2235 PATHSPEC_GLOB |
2236 PATHSPEC_ICASE |
2237 PATHSPEC_EXCLUDE |
2238 PATHSPEC_ATTR);
2239
2240 for (i = 0; i < pathspec->nr; i++) {
2241 const struct pathspec_item *item = &pathspec->items[i];
2242 int len = item->nowildcard_len;
2243
2244 if (len > pathlen)
2245 len = pathlen;
2246 if (!ps_strncmp(item, item->match, path, len))
2247 return 0;
2248 }
2249
2250 return 1;
2251}
2252
2253/*
2254 * This function tells us whether an excluded path matches a

Callers 1

treat_pathFunction · 0.85

Calls 1

ps_strncmpFunction · 0.85

Tested by

no test coverage detected