find DIR -name G: DIR's manifests (to -maxdepth) whose name matches. */
| 1227 | |
| 1228 | /* find DIR -name G: DIR's manifests (to -maxdepth) whose name matches. */ |
| 1229 | static int sh_t_found(sh_t *s, const char *dir, const sh_find_t *f, sh_targets_t *out) { |
| 1230 | const sh_paths_t *m = &s->ix->manifests; |
| 1231 | char key[CBM_SZ_4K]; |
| 1232 | int lo = 0; |
| 1233 | int hi = 0; |
| 1234 | int added = 0; |
| 1235 | if (!sh_dir_exists(s->ix, dir)) { |
| 1236 | return 0; |
| 1237 | } |
| 1238 | sh_range(m, dir, key, sizeof(key), &lo, &hi); |
| 1239 | size_t kl = strlen(key); |
| 1240 | for (int i = lo; i < hi; i++) { |
| 1241 | atomic_fetch_add_explicit(&g_sh_candidates, SKIP_ONE, memory_order_relaxed); |
| 1242 | const char *rest = m->items[i] + kl; |
| 1243 | int depth = SKIP_ONE; |
| 1244 | for (const char *p = rest; *p; p++) { |
| 1245 | depth += *p == '/'; |
| 1246 | } |
| 1247 | const char *base = sh_basename(rest); |
| 1248 | if ((f->maxdepth == SH_NO_DEPTH || depth <= f->maxdepth) && |
| 1249 | (!f->name || sh_glob_seg(f->name, strlen(f->name), base, strlen(base)))) { |
| 1250 | added += sh_add_manifest(s, m->items[i], out); |
| 1251 | } |
| 1252 | } |
| 1253 | return added; |
| 1254 | } |
| 1255 | |
| 1256 | /* -k DIR / kustomize build DIR: the Kustomization of DIR. */ |
| 1257 | static int sh_t_kust(sh_t *s, const char *dir, const sh_find_t *f, sh_targets_t *out) { |
nothing calls this directly
no test coverage detected