MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / sh_t_found

Function sh_t_found

src/pipeline/pass_shell.c:1229–1254  ·  view source on GitHub ↗

find DIR -name G: DIR's manifests (to -maxdepth) whose name matches. */

Source from the content-addressed store, hash-verified

1227
1228/* find DIR -name G: DIR's manifests (to -maxdepth) whose name matches. */
1229static 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. */
1257static int sh_t_kust(sh_t *s, const char *dir, const sh_find_t *f, sh_targets_t *out) {

Callers

nothing calls this directly

Calls 5

sh_dir_existsFunction · 0.85
sh_rangeFunction · 0.85
sh_basenameFunction · 0.85
sh_glob_segFunction · 0.85
sh_add_manifestFunction · 0.85

Tested by

no test coverage detected