Skip to content

Native Git Diff Driver

In v0.5.0, symtrace’s git-diff-driver subcommand operates with full repository context-awareness and Two-Tier CAS Diff Caching. When Git invokes external diff drivers on temporary files, symtrace resolves local repository context to preserve cross-file symbol movement tracking, downstream blast radius calculation, and .scm query DSL evaluation.

git diff ──► .gitattributes filter ──► symtrace git-diff-driver ──► Context-Aware AST Diff
Terminal window
# Global configuration (applies to all Git repositories)
git config --global diff.symtrace.command "symtrace git-diff-driver"
# OR local configuration (applies only to current repository)
git config diff.symtrace.command "symtrace git-diff-driver"

In your repository root, add or update your .gitattributes file:

# Map supported language files to symtrace semantic diff
*.rs diff=symtrace
*.js diff=symtrace
*.jsx diff=symtrace
*.ts diff=symtrace
*.tsx diff=symtrace
*.py diff=symtrace
*.java diff=symtrace
*.c diff=symtrace
*.h diff=symtrace
*.cpp diff=symtrace
*.hpp diff=symtrace
*.go diff=symtrace
*.cs diff=symtrace
*.rb diff=symtrace
*.php diff=symtrace
*.json diff=symtrace

When you execute standard Git commands like git diff, Git inspects .gitattributes. When a file matches a rule with diff=symtrace, Git executes the driver command with 7 positional arguments:

Terminal window
symtrace git-diff-driver <path> <old-file> <old-hex> <old-mode> <new-file> <new-hex> <new-mode>

In v0.5.0, the git-diff-driver subcommand:

  1. Resolves local Git repository state from <path> to re-establish global context.
  2. Queries the Two-Tier CAS Diff Cache keyed by <old-hex> and <new-hex> for under 0.004 ms execution.
  3. Performs 6-stage AST matching, safety contract checking, and custom .scm query DSL evaluation.
  4. Outputs formatted ANSI semantic badges with adaptive granularity directly to Git’s standard pager pipeline.
Terminal window
# Show semantic diff of modified files in working tree
git diff
# Show semantic diff of staged files
git diff --staged
# Show semantic diff between two commits or branches
git diff main feature-branch
# Bypass git-diff-driver and force raw line diff for one command
git diff --no-ext-diff