Skip to main content

Module git

Module git 

Source
Expand description

Git integration for change tracking Git integration for change-aware index updates

This module provides git-based change detection to enable 10-100x faster incremental index builds by processing only files that have changed since the last index build.

§Architecture

The module uses a trait-based design to support multiple backends:

  • SubprocessGit: Subprocess-based git command execution (current)
  • NoGit: Fallback when git is unavailable (always returns empty changes)
  • Future: Git2Backend for libgit2-based implementation (enterprise)

§Security

  • All git commands use Command::new("git") with array arguments (no shell)
  • File paths are canonicalized and validated to remain under workspace root
  • Environment variables are validated and clamped to safe ranges
  • Git command output is limited to 10MB to prevent memory exhaustion
  • Timeouts enforce SIGTERM then SIGKILL process cleanup

§Example

use sqry_core::git::{GitChangeTracker, ChangeSet};
use std::path::Path;

let workspace = Path::new("/path/to/repo");
let mut tracker = GitChangeTracker::new(workspace)?;

// Detect changes since last indexed commit
let baseline = Some("abc123");
let (changes, new_head) = tracker.detect_changes(baseline)?;

println!("Changed files: {}", changes.total());
println!("New HEAD: {:?}", new_head);

Re-exports§

pub use recency::RecencyIndex;

Modules§

recency
Recency scoring for hybrid search based on git commit timestamps

Structs§

ChangeSet
Represents a set of file changes detected by git
GitCapabilities
Backend-specific capabilities
GitChangeTracker
High-level facade for git change tracking
NoGit
No-op git backend that always reports no changes
SubprocessGit
Subprocess-backed git integration
WorktreeManager
Manages temporary git worktrees with RAII cleanup guarantees.

Enums§

GitError
Errors that can occur during git operations

Traits§

GitBackend
Git backend abstraction for change detection

Functions§

max_git_output_size
Get maximum git output size, respecting environment variable override
parse_diff_name_status
Parse git diff --name-status -z output
parse_porcelain
Parse git status --porcelain=v1 -z output

Type Aliases§

Result
Result type for git operations