Add clean-slate design doc and begin gitoxide migration of git wrapper#75
Conversation
Co-Authored-By: Şahin Olut <olut.sahin@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
⚙️ Control Options:
|
Co-Authored-By: Şahin Olut <olut.sahin@gmail.com>
Co-Authored-By: Şahin Olut <olut.sahin@gmail.com>
Co-Authored-By: Şahin Olut <olut.sahin@gmail.com>
There was a problem hiding this comment.
we should have GixBackend and GitBackend, so the methods like rev_parse should be part of the interface definition and they are shared, instead of if/else should use paths like: https://github.com/0lut/gitmirrorcache/pull/75/changes#diff-33ad69c17787788f144c92e52eed95296ddecf90a61fdf0de42c368d908857f1R166-R171
There was a problem hiding this comment.
Done in 76b4dcd: added a LocalGitBackend trait with GixBackend and GitBackend implementations (new crates/git-cache-git/src/backend.rs). rev_parse, is_ancestor, for_each_ref/for_each_ref_commits, and cat_file_batch_types are now part of the shared interface; the Git wrapper just validates inputs and delegates to self.local_backend — no more if use_gitoxide branches. with_gitoxide(bool) now swaps the backend Arc so the existing config/env kill switch and parity test keep working.
Co-Authored-By: Şahin Olut <olut.sahin@gmail.com>
Co-Authored-By: Şahin Olut <olut.sahin@gmail.com>
Summary
Commits the clean-slate read-through cache design write-up as
docs/clean-slate-design.mdand starts the highest-leverage bet from it: serving Git operations in-process via gitoxide (gix) instead of shelling out to thegitbinary.This first slice migrates the five lowest-risk operations — all local, read-only, never touching the network:
rev_parse→gix::Repository::rev_parse_singlefor_each_ref/for_each_ref_commits→references().prefixed(prefix)(symbolic refs followed without peeling annotated tags, matching%(objectname))is_ancestor→rev_walk([ancestor]).with_hidden([descendant])is-empty check (mirrorsrev-list --max-count=1 A --not B)cat_file_batch_types→try_find_headerper id, missing objects skipped (mirrorscat-file --batch-check; gix never lazy-fetches, so this also covers theGIT_NO_LAZY_FETCHvariant)Wiring:
gix_backendmodule ingit-cache-gitwith sync implementations run viaspawn_blocking, bounded by the same semaphore as git subprocesses; repos opened withgix::open::Options::isolated()(no user/system config), mirroring the subprocessenv_clearhygiene.reject_revision_arg,reject_ref_arg) still runs first even though there's no argv to inject into.AppConfig.use_gitoxide(envGIT_CACHE_USE_GITOXIDE, default true);Git::with_gitoxide(false)routes everything back through thegitbinary.gix 0.84pinned withdefault-features = false, features = ["revision", "sha1"]— no network features compiled in.Testing: new
gitoxide_backend_matches_subprocess_backendparity test asserts identical results from both backends for every migrated operation (including missing-object and self-ancestor edge cases); the full existing suite now exercises the gix path by default since the flag defaults to on.Network operations (
fetch_*,ls_remote_*,upload_pack_spawn) intentionally stay on the subprocess path; they migrate in later PRs per the design doc.Link to Devin session: https://app.devin.ai/sessions/a5e627993756406f84d6d0b40d3a4165
Requested by: @0lut