Skip to content

[05/08] replace mutating git action paths and network operation plumbing#99

Open
mjc wants to merge 44 commits into
asinglebit:mainfrom
mjc:mjc/gitoxide-spike-05-actions-network
Open

[05/08] replace mutating git action paths and network operation plumbing#99
mjc wants to merge 44 commits into
asinglebit:mainfrom
mjc:mjc/gitoxide-spike-05-actions-network

Conversation

@mjc

@mjc mjc commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Stacked on mjc/gitoxide-spike-04-queries-readonly.

Why this PR exists:

  • Earlier stack layers moved graph traversal and read-only query paths toward gitoxide.
  • This PR starts the mutating-action migration.
  • The main goal is to introduce a shared gix action boundary and migrate the action families that need direct ref, config, index, checkout, auth, network, and submodule plumbing.
  • Some action families remain mixed or unchanged in this layer. In particular, pushing and resetting are covered by tests here but are not substantially rewritten in this patch.

What changed:

  • Adds git::actions::gix_support as the shared helper layer for mutating gix operations:
    • opening worktree repos
    • building branch, remote-tracking, and HEAD ref names
    • converting gix errors into the existing git2::Error shape
    • editing repository config files
    • writing gix indexes
    • updating HEAD to an object or symbolic ref
    • checking out a tree through gix worktree checkout
  • Migrates local branch actions to gix refs/config operations:
    • create branch
    • delete branch
    • rename branch
    • update/remove branch config where needed
    • protect deletion of the current branch
  • Migrates checkout actions to gix:
    • detached commit checkout
    • existing local branch checkout
    • remote-tracking branch checkout by creating a local branch
    • upstream config setup for newly-created local tracking branches
    • forced tree checkout through gix worktree checkout
  • Migrates fetch to gix network plumbing:
    • opens the repo through gix
    • resolves the remote and fetch URL
    • installs explicit head/tag fetch refspecs
    • connects through gix remote fetch
    • receives the pack through gix
    • uses the new gix credential adapter
  • Extends auth with gix credential support:
    • HTTP/HTTPS credentials
    • SSH credentials
    • default SSH key lookup helper
    • fallback to gix built-in credentials where the app session has no answer
  • Migrates tag create/delete to gix ref operations.
  • Migrates submodule actions toward gix:
    • sync submodule URL from .gitmodules
    • update checked-out submodule remote URL
    • stage a submodule commit pointer in the superproject index
    • unstage a submodule pointer back to HEAD or remove it from the index
    • initialize/update/fetch/checkout submodules through gix repo, remote, index, and checkout APIs
  • Updates staging so submodule pointer changes use the new submodule query model and stage_submodule_head.
  • Adds or wires inline test modules for action families:
    • branching
    • checkout
    • fetching
    • pushing
    • resetting
    • submodules
    • tagging
    • auth
    • plus existing action tests for merge/rebase/revert/cherry-pick/remotes/worktrees/path behavior

Algorithm difference:

  • Branch creation/deletion/rename no longer goes through libgit2 branch helpers; it uses gix reference transactions and explicit config edits.
  • Checkout no longer goes through git2::checkout_head; it updates HEAD and checks out the target tree through gix.
  • Remote branch checkout creates the local branch, writes upstream config, mirrors the local branch into the in-memory branch map, then checks out the tree.
  • Fetch no longer uses libgit2 RemoteCallbacks/FetchOptions; it uses gix remote connection, refspec setup, credential callbacks, and pack receive.
  • Tagging no longer uses libgit2 lightweight tag helpers; it creates/deletes tag refs through gix.
  • Submodule update no longer delegates to libgit2 SubmoduleUpdateOptions; it opens or initializes the submodule repo, configures its remote, fetches through gix, checks out the target commit tree, and sets HEAD.
  • Staging still uses libgit2 index/status for normal file staging, but submodule pointer handling now goes through the new gix-backed submodule metadata/action path.
  • Pushing and resetting are not materially migrated in this PR.

Performance story:

  • Many paths are dominated by disk writes, checkout work, network transfer, hooks, or remote behavior.
  • The useful improvement is boundary consolidation:
    • fewer ad hoc repo-open paths
    • shared config editing
    • shared ref-name construction
    • shared gix checkout/index helpers
    • shared gix credential adapter
  • Fetch/submodule update may benefit from using the same gix network/auth path as the rest of the stack

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

Ref Total vs main User System CPU
05-actions-network 1.993s 78.91x 1.47s 0.26s 87%

CPU: 5950x Linux/ZFS

Ref Total vs main User System CPU
05-actions-network 1.862s 53.30x 1.60s 0.49s 112%

Memory: 5950x Linux/ZFS

Ref Peak heap Peak RSS
05-actions-network 436.12M 978.61M
Top 10 heaptrack allocation sites for `05-actions-network`
  1. 190825 calls, 11.40M peak - git__calloc
  2. 101577 calls, 0B peak - <>::next
  3. 100831 calls, 0B peak - gix_dir::walk::readdir::recursive
  4. 89663 calls, 1.27M peak - CRYPTO_malloc
  5. 41425 calls, 1.61M peak - <>::finish_grow
  6. 34119 calls, 0B peak - gix_ref::raw::convert::<>::from
  7. 24684 calls, 0B peak - <>::push_back_tracked_path_component
  8. 17060 calls, 878.18K peak - guitar::core::walker::Walker::new
  9. 13654 calls, 0B peak - std::sys::fs::read_dir
  10. 11854 calls, 154.43M peak - alloc::raw_vec::RawVecInner<>::finish_grow

mjc added 30 commits July 1, 2026 12:35
(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)
(cherry picked from commit 6ce842f)
(cherry picked from commit dac26d1)
(cherry picked from commit 77e669a)
(cherry picked from commit 1484548)
Copilot AI review requested due to automatic review settings July 1, 2026 21:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR begins migrating mutating Git actions from libgit2 to gitoxide (gix) by introducing a shared gix “action boundary” layer and moving multiple action/query families (branching/checkout/fetch/tagging/submodules/worktrees) onto gix refs, config, index, checkout, and network/auth plumbing. It also updates core types and tests/benchmarks to support gix OIDs, gix timestamps, and the new behavior boundaries.

Changes:

  • Introduces shared gix support layers (git::actions::gix_support, git::gix) and extends auth with gix credential adapters.
  • Migrates key action families (branching, checkout, fetch, tagging, submodules) to gix-based ref/config/index/checkout/network operations.
  • Updates core models (OIDs, worktrees, submodules, reflogs, layers) and adds/rewires extensive test coverage; adds --exit-when-graph-complete for benchmarking/automation.

Reviewed changes

Copilot reviewed 94 out of 95 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/tests/helpers/localisation.rs Stabilize language tests with guard + tempfile path creation
src/tests/helpers/keymap.rs Add language guard to avoid cross-test localisation leakage
src/tests/helpers/heatmap.rs New unit tests for gix-backed heatmap + OID prefix lookup
src/tests/helpers/branch_visibility.rs Extend coverage for ref parsing + bare repo branch listing
src/tests/git/queries/worktrees.rs Rework tests for new gix-backed worktree query behavior
src/tests/git/queries/remotes.rs Update tests for path-based remote queries + bare repo handling
src/tests/git/queries/reflogs.rs Update reflog tests for gix-backed reflog reading
src/tests/git/queries/files.rs Update tests to use shared test_support helpers
src/tests/git/queries/file_history.rs Expand/adjust file history tests for gix-backed status logic
src/tests/git/os/path.rs Use shared TestDir helper in path tests
src/tests/git/auth.rs Add tests for gix credential adapter + SSH key lookup order
src/tests/git/actions/worktrees.rs Use shared TestDir in worktree action tests
src/tests/git/actions/tagging.rs New tests for gix-backed lightweight tagging
src/tests/git/actions/reverting.rs Refactor revert tests to shared test_support helpers
src/tests/git/actions/resetting.rs New tests for reset behavior across linked worktrees
src/tests/git/actions/remotes.rs Refactor remote action tests to shared temp_repo helper
src/tests/git/actions/rebasing.rs Refactor rebase tests to shared test_support helpers
src/tests/git/actions/pushing.rs New tests for push branch/tags and remote-branch deletion
src/tests/git/actions/fetching.rs New tests for gix-backed fetch + pruning + linked worktrees
src/tests/git/actions/cherrypicking.rs Refactor cherrypick tests to shared test_support helpers
src/tests/git/actions/checkout.rs New tests for gix-backed checkout in linked worktrees
src/tests/git/actions/branching.rs Add/expand tests for gix-backed branching + config behavior
src/tests/core/reflogs.rs Switch core reflog time type expectations to gix time
src/tests/core/oids.rs New unit tests for new Oids intern/prefix behavior
src/tests/app/state/app.rs Add tests for wait_until_graph_complete and graph completion behavior
src/tests/app/input/worktrees.rs Update worktree OID types to gix ObjectId in tests
src/tests/app/input/navigation.rs Stabilize branch-toggle test against varying default branch name + language guard
src/tests/app/input/git.rs Update reflog time type to gix time in tests
src/tests/app/input/events.rs Update worktree/reflog OID/time test helpers to gix equivalents
src/tests/app/draw/worktrees.rs Update WorktreeEntry head OID type in draw tests
src/tests/app/draw/status.rs Update GraphRow defaults to match new struct fields
src/tests/app/draw/settings.rs Add language guard for localisation-sensitive rendering test
src/tests/app/draw/search.rs Stop using short_oid field; derive display from OID
src/tests/app/draw/graph.rs Update GraphRow defaults + GraphHistory API usage in tests
src/main.rs Add --exit-when-graph-complete mode and repo path parsing
src/lib.rs Expose new git::gix + git::test_support modules; add gix_support
src/helpers/time.rs Add gix time formatting helpers; keep git2 compatibility
src/helpers/heatmap.rs Migrate heatmap counting/building to gix + add streaming HeatmapCounts
src/helpers/branch_visibility.rs Use gix refs enumeration; add UTF-8-safe ref name parsing
src/git/test_support.rs New shared test utilities: repo init/commit helpers, worktree fixtures, language guard
src/git/queries/worktrees.rs Reimplement worktree listing/metadata using gix + add dirty-scan policy options
src/git/queries/remotes.rs Reimplement remote enumeration + default remote resolution using gix config/remotes
src/git/queries/reflogs.rs Reimplement HEAD reflog retrieval using gix reflog APIs
src/git/queries/helpers.rs Treat submodule commit entries as Added in tree walk; simplify hunk/header construction
src/git/queries/files.rs Switch tracked file enumeration to gix index; optimize fuzzy matching with SmallVec
src/git/queries/commits.rs Move tip/tag/stash enumeration + batching integration toward gix
src/git/gix.rs New gix helper module: cache sizing, branch tip iteration, error conversion
src/git/auth.rs Add gix credential adapter + make SSH key lookup testable
src/git/actions/tagging.rs Migrate lightweight tagging to gix ref transactions + add tests
src/git/actions/submodules.rs Migrate submodule sync/stage/unstage/update plumbing to gix
src/git/actions/staging.rs Stage submodule pointers via new submodule model + stage_submodule_head
src/git/actions/resetting.rs Wire in resetting tests module
src/git/actions/pushing.rs Wire in pushing tests module
src/git/actions/gix_support.rs New shared mutating gix helper layer (open repo/config edit/index write/head/checkout)
src/git/actions/fetching.rs Migrate fetch to gix network plumbing + prune stale remote-tracking refs + add tests
src/git/actions/checkout.rs Migrate checkout (detached/local/remote-tracking bootstrap) to gix refs/config/checkout
src/git/actions/branching.rs Migrate create/delete/rename to gix ref transactions + explicit config edits
src/core/worktrees.rs Change worktree HEAD type to gix ObjectId
src/core/submodules.rs Change submodule OID fields to gix ObjectId
src/core/reflogs.rs Change reflog time type to gix time
src/core/oids.rs Rewrite Oids intern/prefix logic around gix ObjectId + IdHashMap
src/core/layers.rs Reduce allocations by storing symbols as &str and flattened lanes as bytes; add unit tests
src/core/chunk.rs Make Chunk Copy
src/app/input/worktrees.rs Update alias lookup to new Oids API
src/app/input/remotes.rs Pass repo path into new path-based remote query API
src/app/input/navigation.rs Adjust commit lookup and alias lookup for new Oids API
src/app/input/modals.rs Replace OID prefix search with Oids prefix API
src/app/input/git.rs Switch default remote lookup to path-based API; adjust alias/oid getters
src/app/draw/stashes.rs Adjust OID retrieval API usage
src/app/draw/settings.rs Switch remotes rendering to path-based queries
src/app/draw/search.rs Derive short OID display directly from OID formatting
src/app/draw/inspector.rs Use gix time formatting for gix reflog entries
src/app/draw/graph.rs Generalize line alignment function lifetime
src/app/app.rs Add bootstrap/shutdown/wait-for-graph APIs; handle graph channel disconnect; accept worktree graph events
Cargo.toml Add gix + supporting deps (iddqd, rustc-hash, smallvec, gix-worktree crates)
benches/render_graph_projection.rs Refactor benchmark setup for updated GraphRow fields
benches/fixtures.rs Update benchmark fixtures for new GraphRow fields
benches/commit_batching.rs Update benchmarks for new Batcher API + gix repo usage

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/git/actions/gix_support.rs
Comment thread src/git/actions/gix_support.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants