---
id: ab978b5d-a377-49fe-bb7f-1c6a013a60fe
title: Git reader module (log/tree/show/diff/bundle/tarball)
state: closed
labels:
- area:git
assignees: []
milestone: m1-code-tab
created: 2026-09-10T03:52:24.202409062Z
updated: 2026-09-10T04:04:31.370381550Z
---
Context: All pages need git data via CLI (no libgit2). Shared module used by code/commits/releases/bundle.
Tasks:
- Module `gitx`: `resolve_branch(repo, flag|env|main->master)`, `rev_parse_short`, `log_n(100): sha,subject,author,date`, `ls_tree(branch, path)`, `show(branch:path)->bytes`, `diff(sha)->unified text (capped, binary-aware)`.
- Shells out to `git -C <repo>` with timeout; non-UTF8 paths handled (lossy display + raw still exact); errors are typed, never panic.
- `snapshot(repo, branch, out)`: `git bundle create repo.bundle <branch>` + `repo.tar.gz` via `git archive`.
- Unit tests with a temp fixture repo (init, 3 commits, branch, binary file).
Success rubric:
- [ ] Tests green on fixture: log order, ls-tree dirs-first sort, show byte-exact, diff contains expected hunk, bundle clones (`git clone repo.bundle` works), tarball extracts.
- [ ] Missing branch -> loud error naming tried names. Non-repo path -> clean error, exit non-zero.
- [ ] No git command exceeds 10s (timeout tested with mocked GIT ceiling? at least timeout plumbed).
Swarm: Owl/Platinum. Branch `m1/gitx`. No HTML in this issue.
