Skip to content

Add clean-slate design doc and begin gitoxide migration of git wrapper#75

Merged
0lut merged 7 commits into
mainfrom
devin/1781080684-gitoxide-migration-plan
Jun 10, 2026
Merged

Add clean-slate design doc and begin gitoxide migration of git wrapper#75
0lut merged 7 commits into
mainfrom
devin/1781080684-gitoxide-migration-plan

Conversation

@0lut

@0lut 0lut commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

Commits the clean-slate read-through cache design write-up as docs/clean-slate-design.md and starts the highest-leverage bet from it: serving Git operations in-process via gitoxide (gix) instead of shelling out to the git binary.

This first slice migrates the five lowest-risk operations — all local, read-only, never touching the network:

  • rev_parsegix::Repository::rev_parse_single
  • for_each_ref / for_each_ref_commitsreferences().prefixed(prefix) (symbolic refs followed without peeling annotated tags, matching %(objectname))
  • is_ancestorrev_walk([ancestor]).with_hidden([descendant]) is-empty check (mirrors rev-list --max-count=1 A --not B)
  • cat_file_batch_typestry_find_header per id, missing objects skipped (mirrors cat-file --batch-check; gix never lazy-fetches, so this also covers the GIT_NO_LAZY_FETCH variant)

Wiring:

  • New gix_backend module in git-cache-git with sync implementations run via spawn_blocking, bounded by the same semaphore as git subprocesses; repos opened with gix::open::Options::isolated() (no user/system config), mirroring the subprocess env_clear hygiene.
  • Argument validation (reject_revision_arg, reject_ref_arg) still runs first even though there's no argv to inject into.
  • Kill switch: AppConfig.use_gitoxide (env GIT_CACHE_USE_GITOXIDE, default true); Git::with_gitoxide(false) routes everything back through the git binary.
  • gix 0.84 pinned with default-features = false, features = ["revision", "sha1"] — no network features compiled in.

Testing: new gitoxide_backend_matches_subprocess_backend parity 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

Co-Authored-By: Şahin Olut <olut.sahin@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

devin-ai-integration Bot and others added 3 commits June 10, 2026 08:48
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>

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@0lut
0lut merged commit 1ebd6df into main Jun 10, 2026
18 checks passed
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.

1 participant