Commit Graph
5 Commits
Author SHA1 Message Date
Andrew Hundt 7a32d9a29f refactor(git): reuse portable existence checks
Replace existence-only stat() probes in git context resolution and watcher baseline initialization with cbm_file_exists().

This removes direct sys/stat dependencies from those files without changing behavior: both paths only needed to know whether the root path exists before attempting git snapshot/command handling.

Validation: make -f Makefile.cbm cbm; CBM_ONLY_SUITE=pipeline,tool_consolidation,mcp ./build/c/test-runner; scripts/check-source-safety.sh; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-01 22:48:45 -04:00
Andrew Hundt ec70db30fb feat(git): add reusable snapshot provider
Add a shared git snapshot provider for HEAD, dirty worktree hash, and tracked file count. The provider uses the existing portable command fallback, streams status output with O(1) buffer memory, keeps clean trees unambiguous, and supports non-git fallback without changing incremental defaults.

Migrate watcher polling to the provider with flags so baseline still avoids dirty-status work, normal polls check HEAD plus dirty state, and post-index refresh updates HEAD, dirty hash, and file count together.

Validation: git diff --check; bash scripts/check-source-safety.sh; make -j8 -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=watcher ./build/c/test-runner. Pipeline suite also passed after adding git_snapshot to the shared test runner link before the final dirty-hash clean-state tweak.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-01 05:32:54 -04:00
Andrew Hundt 8b90873a2b refactor(git): share command helpers
Centralize git command formatting, path validation, null-device selection, first-line capture, and command-size checks for git context and watcher code.

This keeps the current command fallback behavior, makes Windows shell metacharacter handling consistent, replaces a touched watcher strdup path with cbm_strdup, and prepares the next git snapshot/pre-discovery acceleration slice without adding a new default route.

Validation: git diff --check; bash scripts/check-source-safety.sh; make -j8 -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=watcher ./build/c/test-runner; CBM_ONLY_SUITE=pipeline ./build/c/test-runner.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-01 05:17:23 -04:00
Andrew Hundt 5e960c999c refactor(git): reuse common allocation constants
Remove git_context.c's private strdup helper and replace literal command/output buffer sizes with CBM-prefixed constants backed by the repository size constants.

This is a prerequisite cleanup for a future shared git snapshot boundary; it does not change command syntax, dependencies, pipeline routing, stdout/stderr behavior, or default incremental behavior.

Validation: git diff --check; bash scripts/check-source-safety.sh; make -j8 -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=pipeline ./build/c/test-runner (282 passed).
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-01 05:05:16 -04:00
pcristin 1519f8619a feat(git): add worktree branch roots
Signed-off-by: pcristin <xxxokzxxx@protonmail.com>
2026-06-19 13:56:17 +02:00