~bigbes/sr-ht-compare: 9473e260

gitx: repository access and ref-to-ref diffs on go-git

Implement the git access layer for compare.sr.ht on go-git v5 (no runtime
git binary). Public surface: Open (owner/name validated via core, bare-repo
HEAD check, ErrNotFound on any miss); Refs/DefaultBranch; ResolveCommit/Log/
Parents; Diff/RawDiff/DiffStat/MergeBase/CommitPatch.

- Diffs route through DiffTreeWithOptions(DetectRenames) so old/new tree order
  is explicit: three-dot uses the merge base as old side, two-dot uses base;
  CommitPatch diffs a commit against its parent (root vs empty tree, merge vs
  first parent, ParentSHAs exposed for the banner).
- Patch text is generated in memory then capped (5 MiB page, 50 MiB raw,
  injectable override for tests) and cut at a "diff --git" file boundary so the
  browser parser never sees a torn hunk; ctx timeout (10s) guards runaways.
- FileChange status/counts/binary derived purely from go-git FilePatches
  (mapFilePatches); Log excludes base's full reachable set for correct
  base..head semantics.

Tests build fixtures by driving the real git CLI in t.TempDir(). Fidelity gate
(TestPatchFidelity) confirms go-git emits standard git headers — diff --git,
index, rename from/to, "Binary files ... differ", @@ hunks — parseable by the
frontend parsePatchFiles(). 82% coverage.

core validators reject ^/~ so navigation revs are resolved to SHAs in tests.

bigbes <bigbes@gmail.com> — 2026-07-18 17:59:28 UTC

Commit 9473e2606cd90cb8d3b78ee87511c671157439f4view raw patch

Parent(s): 94142bd8

10 changed file(s)

FileStatus+
gitx/diff.go A +259
gitx/fidelity_test.go A +125
gitx/fixture_test.go A +150
gitx/gitx.go A +159
gitx/gitx_test.go A +387
gitx/log.go A +132
gitx/mapping_test.go A +159
gitx/refs.go A +113
go.mod M +21 -4
go.sum M +53