[04/08] replace read-only git query paths with gitoxide#98
Conversation
(cherry picked from commit 122fdf1)
Wire a no-TUI entry point that loads the repo, skips workdir status to avoid case-colliding paths on case-insensitive filesystems, waits for the graph walker to finish, prints the commit count, and shuts down background tasks.
(cherry picked from commit 4b30648)
(cherry picked from commit 427dce7)
(cherry picked from commit 9854674)
There was a problem hiding this comment.
Pull request overview
This PR continues the staged migration of read-only Git query surfaces away from libgit2 and onto gitoxide (gix), updating both production query paths (status/metadata/remotes/submodules/worktrees/branch visibility/file history) and the surrounding model/test infrastructure to use gix-native identifiers and time types.
Changes:
- Port read-only query implementations (status matrix, tracked-file search, remotes/default remote selection, submodules, worktrees, branch visibility, reflogs, file history) to gix-based APIs while retaining libgit2 where still required for diffs/hunks.
- Update core model types to use
gix::ObjectIdandgix::date::Time, and refactor graph-walking plumbing to center aroundgix::Repository. - Add/refresh extensive test coverage and shared test fixtures via
git::test_support, plus a new--exit-when-graph-completeCLI mode.
Reviewed changes
Copilot reviewed 75 out of 76 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/main.rs |
Adds --exit-when-graph-complete mode and repo path parsing changes. |
src/lib.rs |
Exposes new git::gix and git::test_support modules. |
Cargo.toml |
Introduces gix and supporting crates (iddqd, smallvec, etc.) for the migration. |
src/helpers/time.rs |
Adds gix time formatting helpers while preserving git2 timestamp APIs. |
src/helpers/heatmap.rs |
Reworks heatmap counting/building to use gix commit lookup and a compact counts buffer. |
src/helpers/branch_visibility.rs |
Moves branch-name enumeration to gix refs and adds UTF-8-only ref parsing helper. |
src/git/gix.rs |
Adds shared gix utilities (error mapping, branch tip iteration, object cache enabling). |
src/git/test_support.rs |
New shared test fixtures/helpers for repositories, commits, worktrees, remotes, submodules, and language isolation. |
src/git/queries/diffs.rs |
Migrates workdir/index status path collection to gix and normalizes staged-only computation. |
src/git/queries/files.rs |
Switches tracked-file enumeration to gix index iteration; refactors fuzzy matcher around SmallVec. |
src/git/queries/remotes.rs |
Moves remote listing/default-remote resolution to gix remotes + config snapshot reads. |
src/git/queries/submodules.rs |
Rewrites submodule metadata/status collection around gix submodule APIs and .gitmodules preflight. |
src/git/queries/worktrees.rs |
Migrates worktree listing/metadata/dirty policy to gix worktree proxies and status scanning. |
src/git/queries/reflogs.rs |
Switches reflog reading to gix reference log iteration and gix-native time/OIDs. |
src/git/queries/file_history.rs |
Reimplements file history status classification using gix tree diffs with caching. |
src/git/queries/helpers.rs |
Adjusts tree walking/diff hunk shaping for gitlink entries and new string handling. |
src/git/queries/commits.rs |
Ports tip/tag/stash/root enumeration and batching plumbing to gix-based traversal. |
src/core/oids.rs |
Replaces OID aliasing map with iddqd-backed intern table and adds prefix lookup support. |
src/core/walker.rs |
Converts graph walker to operate on gix::Repository, gix-derived roots, and streamed commit metadata. |
src/core/worktrees.rs |
Updates worktree head IDs to gix::ObjectId. |
src/core/submodules.rs |
Updates submodule head/index/workdir IDs to gix::ObjectId. |
src/core/reflogs.rs |
Moves reflog entry time to gix::date::Time. |
src/core/layers.rs |
Refactors renderer-layer token storage to avoid allocations and use compact lane flags. |
src/core/chunk.rs |
Makes Chunk Copy to support updated buffer semantics. |
src/app/app.rs |
Adds bootstrap/shutdown/wait helpers; improves graph channel disconnect handling; wires new worktrees event. |
src/app/input/git.rs |
Updates stash/reflog flows and default-remote selection to the new gix-backed queries. |
src/app/input/modals.rs |
Switches SHA prefix resolution to Oids::get_alias_by_prefix. |
src/app/input/remotes.rs |
Adjusts remote URL lookup to use new list_remotes(path) API. |
src/app/input/navigation.rs |
Updates commit lookups and alias resolution to new Oids API shape. |
src/app/input/worktrees.rs |
Updates worktree alias resolution to new Oids::get_existing_alias. |
src/app/draw/inspector.rs |
Uses gix timestamp formatting for reflog display. |
src/app/draw/search.rs |
Renders short OID directly from oid rather than a stored short_oid field. |
src/app/draw/graph.rs |
Adjusts alignment helper lifetimes for non-'static spans. |
src/app/draw/settings.rs |
Switches remotes listing/default remote rendering to new path-based API. |
src/app/draw/stashes.rs |
Updates Oid lookup call sites after Oids API changes. |
src/core/worktrees.rs |
Updates worktree head type to gix OIDs for the UI model. |
src/tests/helpers/localisation.rs |
Adds language guard + temp file path handling changes for isolation. |
src/tests/helpers/keymap.rs |
Adds language guard and removes manual language reset. |
src/tests/helpers/branch_visibility.rs |
Refactors temp paths to shared test_support + adds additional branch parsing/path coverage. |
src/tests/helpers/heatmap.rs |
New tests for gix-backed heatmap counting and prefix matching behavior. |
src/tests/git/queries/diffs.rs |
Updates diff/status tests to validate new gix status matrix behavior. |
src/tests/git/queries/files.rs |
Updates file-search tests and adds staged/deleted enumeration coverage. |
src/tests/git/queries/remotes.rs |
Updates remotes tests for path-based gix APIs + bare repo coverage. |
src/tests/git/queries/submodules.rs |
Expands submodule tests for .gitmodules preflight, index scanning, bare repos, and state flags. |
src/tests/git/queries/worktrees.rs |
Adds worktree metadata vs dirty policy tests + lock/prune semantics coverage. |
src/tests/git/queries/reflogs.rs |
Updates reflog tests to gix repo access and new filtering semantics. |
src/tests/git/queries/file_history.rs |
Updates file history tests to use gix repo + adds copy/typechange/normalization coverage. |
src/tests/git/actions/submodules.rs |
Adjusts submodule action tests to gix OID conversions. |
src/tests/git/actions/{reverting,rebasing,merging,cherrypicking,branching}.rs |
Refactors temp repo setup to shared init_repo_at. |
src/tests/core/{walker,buffer,reflogs,oids}.rs |
Updates/extends core tests for new gix-based walker/OID/buffer semantics. |
src/tests/app/state/app.rs |
Adds tests for wait_until_graph_complete behavior and updates row structs. |
src/tests/app/input/{navigation,git,events,worktrees}.rs |
Updates tests for new OID/time types and language guard usage. |
src/tests/app/draw/{graph,search,status,settings,worktrees}.rs |
Updates rendering tests for model shape changes and language isolation. |
benches/{commit_batching,fixtures,render_graph_projection}.rs |
Updates benches to the new gix-backed walker/batcher plumbing and row defaults. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| fn repo_path_from_args(args: &[String]) -> Option<String> { | ||
| args.iter().skip(1).find(|arg| !arg.starts_with('-')).cloned() | ||
| } |
| lines.push(Line::from(vec![ | ||
| Span::styled(format!("{} ", status_marker(row.status, &self.symbols)), Style::default().fg(marker_color)), | ||
| Span::styled(format!("{} ", row.short_oid), Style::default().fg(self.theme.COLOR_GREY_600)), | ||
| Span::styled(format!("{:.8} ", row.oid), Style::default().fg(self.theme.COLOR_GREY_600)), | ||
| Span::styled(truncate_with_ellipsis(&row.summary, summary_width), Style::default().fg(self.theme.COLOR_TEXT)), |
There was a problem hiding this comment.
bogus comment I am nearly certain
| let ids = (tree_id, parent_tree_id); | ||
| COMMIT_TREE_CACHE.with(|cache| { | ||
| cache.borrow_mut().insert(oid, ids); | ||
| }); | ||
| Ok(ids) | ||
| } |
There was a problem hiding this comment.
worthwhile target for a future pr but I think it was added in an earlier pr in the stack.
Stacked on
mjc/gitoxide-spike-03-graph-walker.Why this PR exists:
What changed:
get_filenames_diff_at_workdirnow opens a gix repo and iterates gix status items.UncommittedChangesshape.SmallVecand split the position/scoring logic into smaller helpers..gitmodulesin workdir, committed tree, and index.gix::ObjectId.gix::ObjectId.gix::date::Time.gix::ObjectId.gix::ObjectId.Algorithm difference:
git2::statusesas the main source of staged/unstaged file classification.guitar.defaultRemoteremote.pushDefaultoriginPerformance story:
.gitmodulesmetadata.Benchmark Results for this PR
Command shape:
hyperfine --warmup 5 './target/release/guitar /home/mjc/src/linux --exit-when-graph-complete'.CPU: M1 MacBook Pro 16GB
04-queries-readonly3.812s41.26x1.47s0.42s49%CPU: 5950x Linux/ZFS
04-queries-readonly1.856s53.47x1.58s0.46s110%Memory: 5950x Linux/ZFS
04-queries-readonly436.12M977.18MTop 10 heaptrack allocation sites for `04-queries-readonly`
190825 calls, 11.40M peak - git__calloc101577 calls, 0B peak - <>::next100831 calls, 0B peak - gix_dir::walk::readdir::recursive89663 calls, 1.27M peak - CRYPTO_malloc41425 calls, 1.61M peak - <>::finish_grow34119 calls, 0B peak - gix_ref::raw::convert::<>::from24684 calls, 0B peak - <>::push_back_tracked_path_component17060 calls, 878.18K peak - guitar::core::walker::Walker::new13654 calls, 0B peak - std::sys::fs::read_dir11856 calls, 154.43M peak - alloc::raw_vec::RawVecInner<>::finish_grow