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

Function sig_fold_path_stat

src/watcher/watcher.c:661–676  ·  view source on GitHub ↗

Fold a listed path's (size, mtime) into the signature so an in-place edit * of an already-dirty file still produces a new signature. A failed stat * (deleted file, quoting artifact) degrades to the entry text alone — the * deletion itself is represented by the porcelain status. * * cbm_path_info_utf8 rather than raw stat(): on Windows, stat()'s st_mtime * is SECOND-granularity, so two edits

Source from the content-addressed store, hash-verified

659 * onto root_path directly. cdup is "" when the project IS the repository root,
660 * which reduces this to the original join. */
661static uint64_t sig_fold_path_stat(uint64_t h, const char *root_path, const char *cdup,
662 const char *rel) {
663 char abs[CBM_SZ_4K];
664 snprintf(abs, sizeof(abs), "%s/%s%s", root_path, cdup ? cdup : "", rel);
665 cbm_path_info_t info;
666 int rc = cbm_path_info_utf8(abs, &info);
667 if (rc != 0) {
668 cbm_usleep(1000);
669 rc = cbm_path_info_utf8(abs, &info);
670 }
671 if (rc == 0) {
672 h = sig_fold(h, &info.mtime_ns, sizeof(info.mtime_ns));
673 h = sig_fold(h, &info.size, sizeof(info.size));
674 }
675 return h;
676}
677
678/* Signature of the current dirty state: FNV-1a over the entries of
679 * `git status --porcelain -uall -z` plus each listed path's (size, mtime).

Callers 1

git_dirty_signatureFunction · 0.85

Calls 2

cbm_path_info_utf8Function · 0.85
sig_foldFunction · 0.85

Tested by

no test coverage detected