Replace fragile error message parsing with structured alternatives:
- merge_base: Use exit codes (0=found, 1=orphan, 128+=error) instead of
parsing "no merge base" or "Not a valid commit" strings
- DiffStats: Use --numstat (locale-independent) instead of --shortstat
which uses localized keywords like "insertions"/"Einfügungen"
- Handle orphan branches gracefully: return (0,0) for ahead_behind and
LineDiff::default() for branch_diff_stats instead of erroring
Other changes:
- Add run_command_output helper for inspecting git exit codes
- Simplify DiffStats to use plain usize fields (Option was pointless)
- Add CLAUDE.md guidance about preferring structured output
- Delete unused from_shortstat and its tests
Co-authored-by: Claude <noreply@anthropic.com>
Replace global HashMap cache with direct Arc<RepoCache> ownership on Repository.
Previously, Repository instances looked up their cache in a static
HashMap keyed by git_common_dir. This required computing git_common_dir
to access any cached value and had complexity around lock ordering.
Now:
- Repository holds Arc<RepoCache> directly
- Cloning a Repository shares the cache via Arc
- Parallel tasks (wt list, statusline) clone the Repository
- Tests naturally get isolation since each creates its own Repository
Benefits:
- Simpler mental model: clone = share cache
- No global state coordination
- Clearer ownership semantics
- Removes with_cache() indirection
Co-authored-by: Claude <noreply@anthropic.com>