Commit Graph

2 Commits

Author SHA1 Message Date
Maximilian Roos db4e0e5ddd Use structured output instead of parsing error messages (#570)
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>
2026-01-12 16:35:40 -08:00
Maximilian Roos 3bc243d76f refactor: simplify Repository caching to use Arc-based sharing (#521)
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>
2026-01-10 16:36:57 -08:00