Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Merge remote-tracking branch 'origin/master' into capy/gst-2331-no-lazy-fetch
garrytan2d42bff6b269
diff --cc src/core/persistence/sync-blobs.tsindex 35bf5dc896,9f99b46812..583ebf2717--- a/src/core/persistence/sync-blobs.ts+++ b/src/core/persistence/sync-blobs.ts@@@ -21,9 -20,15 +21,9 @@@ export const SYNC_READ_BOUND = PAGE_MAXexport interface TreeBlob { oid: string; size: number }-/**- * GST-2312 (#9024): the configuration every read here runs with, so no repository-configured program starts: `check-attr`- * reads the index, and reading the index runs `core.fsmonitor`.- */-export const NO_REPOSITORY_PROGRAMS: readonly string[] = ['-c', 'core.fsmonitor=false', '-c', 'core.hooksPath=/dev/null'];-function git(gitRoot: string, args: string[], input?: string, maxBuffer = 32 * 1024 ** 2, env: NodeJS.ProcessEnv = {}): Buffer {- return execFileSync('git', ['-c', 'core.quotepath=false', ...NO_REPOSITORY_PROGRAMS, '--literal-pathspecs', '-C', gitRoot, ...args],- { env: gitChildEnv(env), timeout: 60_000, maxBuffer, stdio: ['pipe', 'pipe', 'pipe'], ...(input !== undefined ? { input } : {}) });+ return execFileSync('git', ['-c', 'core.quotepath=false', ...HARDENED_GIT_ARGS, '--literal-pathspecs', '-C', gitRoot, ...args],- { env: gitChildEnv({ ...NO_LAZY_FETCH_ENV, ...env }), timeout: 60_000, maxBuffer, stdio: ['pipe', 'pipe', 'pipe'], ...(input !== undefined ? { input } : {}) });++ { env: gitChildEnv({ ...(noLazyFetch ? NO_LAZY_FETCH_ENV : {}), ...env }), timeout: 60_000, maxBuffer, stdio: ['pipe', 'pipe', 'pipe'], ...(input !== undefined ? { input } : {}) });}/** At this many paths `readTreeBlobs` lists the whole tree once instead of path chunks (#6712: the prescreen of a tree walk). */@@@ -74,6 -79,14 +74,14 @@@ export function readBlobBytes(gitRoot:}let checkAttrSource: boolean | undefined;+ let noLazyFetch = true;+-/** Test seam: `false` leaves out `GIT_NO_LAZY_FETCH`, as a git older than 2.45 ignores it; returns the restore. */++/** Test seam: `false` leaves `GIT_NO_LAZY_FETCH` out of every read here, as a git older than 2.45 ignores it; returns the restore. */+ export function __setNoLazyFetchForTests(value: boolean): () => void {+ const previous = noLazyFetch;+ noLazyFetch = value;+ return () => { noLazyFetch = previous; };+ }/** Test seam: `false` takes the path of a git older than 2.40; returns the restore. */export function __setCheckAttrSourceForTests(value: boolean | undefined): () => void {@@@ -91,8 -104,10 +99,9 @@@ export interface MissingAttributes { at* committed blob a filter owns holds what the filter's clean program stored (git-crypt ciphertext, for one), not the text* of the checkout, and sync never runs a repository's filters. Git 2.40 and newer read the attributes with* `check-attr --source=<target>`; an older git reads `target` into a temporary index (`read-tree`) and asks- * `check-attr --cached` there. Every call takes `HARDENED_GIT_ARGS` and `GIT_NO_LAZY_FETCH=1`, so no repository- * program runs and a partial clone fetches nothing. Git then reads a `.gitattributes` the repository lacks as empty, so+ * `check-attr --cached` there. Like every read here, each call fetches nothing in a partial clone (GST-2331). Git then reads a `.gitattributes` the repository lacks as empty, so- * the ones that apply are checked first, and a path under a missing one maps to it instead of to a driver.+ * the ones that apply are checked first (a git older than 2.45 fails the batch on a promisor object instead, so each is then checked alone), and a path+ * under a missing one maps to it instead of to a driver and is not passed to `check-attr`.*/export function readFilterDrivers(gitRoot: string, target: string, gitPaths: string[]): Map<string, string | null | MissingAttributes> {const out = new Map<string, string | null | MissingAttributes>();