Step towards git2 to gix conversion#12857
Conversation
|
@Byron is attempting to deploy a commit to the GitButler Team on Vercel. A member of the Team first needs to authorize it. |
cf640a4 to
4a793c4
Compare
git2 to gix conversiongit2 to gix conversion
6deda50 to
e5a3f28
Compare
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
d9b7a5d to
ebea16a
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ebea16af9a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
This PR continues the git2 ➜ gix migration by pushing more internal boundaries and call-sites to be gix-first, reducing git2 dependencies, and consolidating shared Git operations (commit creation/signing and worktree-tree creation) into but-core.
Changes:
- Migrate multiple runtime paths from
git2togix(workspace/worktree, watcher HEAD handling, branch actions, repo adapters, oplog snapshotting). - Consolidate commit signing/creation into
but-core::commitand add dedicated test fixtures/coverage. - Remove/trim legacy
git2surfaces and dependencies (e.g. gitbutler-repo logging module; dropgit2from some crates; update migration plan/inventory).
Reviewed changes
Copilot reviewed 68 out of 69 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| etc/plans/git2-to-gix-migration.md | Updates the migration plan scope, inventory, and workstreams. |
| crates/gitbutler-workspace/src/lib.rs | Removes git2 merge-base usage in workspace base computation. |
| crates/gitbutler-workspace/src/branch_trees.rs | Switches uncommitted-tree capture to gix (via deprecated create_wd_tree). |
| crates/gitbutler-workspace/Cargo.toml | Drops gitbutler-repo dependency. |
| crates/gitbutler-watcher/src/handler.rs | Uses gix to read HEAD referent name/commit. |
| crates/gitbutler-tauri/src/settings.rs | Removes crate-level deprecated allowance. |
| crates/gitbutler-stack/tests/mod.rs | Migrates test traversal/logging usage away from git2-only helpers. |
| crates/gitbutler-repo/tests/hooks.rs | Updates hook tests to call gix-based pre_push. |
| crates/gitbutler-repo/tests/create_wd_tree.rs | Runs create_wd_tree via gix and converts back to git2::Tree for assertions. |
| crates/gitbutler-repo/src/repository_ext.rs | Adds commit_with_signature_gix, migrates remotes/remote-branches toward gix, removes create_wd_tree method. |
| crates/gitbutler-repo/src/remote.rs | Adds GitRemote::from_gix constructor. |
| crates/gitbutler-repo/src/managed_hooks.rs | Adds gix install/uninstall APIs for managed hooks. |
| crates/gitbutler-repo/src/logging.rs | Removes legacy git2 revwalk/logging extension module. |
| crates/gitbutler-repo/src/lib.rs | Re-exports commit_with_signature_gix; introduces signature_gix. |
| crates/gitbutler-repo/src/hooks.rs | Changes pre_push to accept gix::Repository and gix::ObjectId. |
| crates/gitbutler-repo/src/commands.rs | Moves signing check/remotes listing/file reading toward gix. |
| crates/gitbutler-repo/Cargo.toml | Removes but-rebase/but-status deps now covered by but-core. |
| crates/gitbutler-repo-actions/src/repository.rs | Migrates ref ops, distance, and commit creation toward gix helpers. |
| crates/gitbutler-repo-actions/Cargo.toml | Adds direct gix dependency. |
| crates/gitbutler-project/src/project.rs | Removes deprecated open_git2 API. |
| crates/gitbutler-oplog/src/oplog.rs | Migrates snapshot prepare/diff/restore plumbing toward gix IDs and trees, keeping checkout/index boundary where needed. |
| crates/gitbutler-operating-modes/tests/operating_modes.rs | Updates tests to create refs and move HEAD using gix. |
| crates/gitbutler-operating-modes/src/lib.rs | Adds is_well_known_workspace_ref and migrates operating mode HEAD detection to gix. |
| crates/gitbutler-edit-mode/src/lib.rs | Narrows git2 usage, moves ref/HEAD ops toward gix helper(s), keeps checkout/index boundary. |
| crates/gitbutler-edit-mode/Cargo.toml | Drops but-status dependency. |
| crates/gitbutler-branch/src/reference_ext.rs | Removes git2 reference extension; keeps gix-first identity logic. |
| crates/gitbutler-branch/src/lib.rs | Stops exporting removed ReferenceExt (git2). |
| crates/gitbutler-branch/Cargo.toml | Drops git2/itertools dependency. |
| crates/gitbutler-branch-actions/tests/branch-actions/virtual_branches/oplog.rs | Updates oplog tests to use gix snapshot IDs. |
| crates/gitbutler-branch-actions/src/upstream_integration.rs | Migrates merge and workdir-tree acquisition toward gix. |
| crates/gitbutler-branch-actions/src/undo_commit.rs | Removes unnecessary git2<->gix conversions for updated stack head. |
| crates/gitbutler-branch-actions/src/stack.rs | Uses gix for merge-base and pre-push hook invocation inputs. |
| crates/gitbutler-branch-actions/src/squash.rs | Replaces git2 log traversal and commit creation with gix helpers. |
| crates/gitbutler-branch-actions/src/reorder.rs | Migrates merge-base calculation and stack head update to gix IDs. |
| crates/gitbutler-branch-actions/src/integration.rs | Creates workspace commits via gix, adjusts HEAD/ref checks to gix. |
| crates/gitbutler-branch-actions/src/branch_upstream_integration.rs | Removes git2 conversion for stack head update after rebase. |
| crates/gitbutler-branch-actions/src/branch_manager/branch_removal.rs | Uses deprecated gix create_wd_tree for workdir-tree capture. |
| crates/gitbutler-branch-actions/src/branch_manager/branch_creation.rs | Migrates ref lookup/head IDs to gix, keeps wd-tree via deprecated helper. |
| crates/gitbutler-branch-actions/src/base.rs | Migrates base-branch selection/remote URL/ref checks and config edits toward gix. |
| crates/gitbutler-branch-actions/src/actions.rs | Fetches remote names via gix instead of git2 adapter. |
| crates/but/src/command/legacy/teardown.rs | Uses gix managed hook uninstall API. |
| crates/but/src/command/legacy/setup.rs | Uses mutable gix repo handle and reload after remote setup; uses gix managed hook install API. |
| crates/but/src/command/legacy/push.rs | Stores remote ref as gix::refs::FullName and uses but-core remote-name extraction helper. |
| crates/but/src/command/legacy/pick.rs | Decodes commit messages via gix instead of looking up git2 commits. |
| crates/but/src/command/legacy/branch/list.rs | Migrates commit author/time inspection to gix. |
| crates/but/src/command/legacy/branch/apply.rs | Migrates branch partial-match discovery to gix references/categories. |
| crates/but/Cargo.toml | Removes direct git2 and but-oxidize deps from but crate. |
| crates/but-worktrees/src/integrate.rs | Replaces but_status::create_wd_tree with deprecated gix create_wd_tree. |
| crates/but-worktrees/Cargo.toml | Drops but-status dependency. |
| crates/but-workspace/src/legacy/tree_manipulation/split_branch.rs | Replaces git2 logging helper with gix first-parent traversal helper. |
| crates/but-workspace/src/legacy/stacks.rs | Minor doc formatting tweak. |
| crates/but-workspace/src/legacy/head.rs | Migrates workdir tree and commit creation to gix helpers. |
| crates/but-status/src/lib.rs | Removes create_wd_tree implementation; retains get_status. |
| crates/but-status/Cargo.toml | Adds but-core dependency; removes bstr dependency. |
| crates/but-settings/src/lib.rs | Removes crate-level deprecated allowance. |
| crates/but-rebase/src/commit.rs | Delegates commit writing/signing to but-core::commit::create. |
| crates/but-rebase/Cargo.toml | Removes but-error dependency. |
| crates/but-core/tests/fixtures/scenario/single-signed.sh | Adds a signed-commit fixture scenario for but-core tests. |
| crates/but-core/tests/core/commit.rs | Adds tests for commit signing, signature stripping, ref updates, and metadata preservation. |
| crates/but-core/src/worktree/checkout/function.rs | Reuses new update_head_reference helper for HEAD updates. |
| crates/but-core/src/repo_ext.rs | Introduces update_head_reference and moves create_wd_tree onto gix::RepositoryExt (deprecated). |
| crates/but-core/src/lib.rs | Re-exports update_head_reference; adjusts reference display for gix refs. |
| crates/but-core/src/git_config.rs | Adds ensure_config_value helper for multivar config entries. |
| crates/but-core/src/commit.rs | Adds shared commit creation + signing implementation (moved from but-rebase). |
| crates/but-core/Cargo.toml | Adds tempfile dependency for signing implementation. |
| crates/but-api/src/legacy/oplog.rs | Switches restore/diff APIs to gix snapshot IDs. |
| crates/but-api/src/legacy/git.rs | Migrates remote branches and index size queries to gix. |
| Cargo.toml | Updates workspace comment for but-status. |
| Cargo.lock | Updates lockfile for dependency graph changes (e.g. tempfile, removed deps). |
Mostly `git2` removal from `but`, and deduplication and cleanup. Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
Prompt: > Address the following review comments as part of the git2-to-gix conversion: gitbutlerapp#12857 (review) . Then double-check how Git does it in /Users/byron/ dev/github.com/git/git and evaluate or fix "`core.hooksPath` may be set to a relative path; Git resolves it relative to the repository/workdir. Here `trusted_path("core.hooksPath")` is converted to an owned path and used directly for `.exists()`/`.join()`. If the returned path is relative, hook discovery can depend on the process CWD instead of the repo. Consider normalizing relative paths against `repo.workdir()` (or repo root) before using them.". Also switch get_hooks_dir_gix() to use the same trusted_path mechanism as above, probably this wants to be deduplicated. Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
Prompt: > Address the following review comments as part of the git2-to-gix conversion: gitbutlerapp#12857 (review) . Then double-check how Git does it in /Users/byron/ dev/github.com/git/git and evaluate or fix "`core.hooksPath` may be set to a relative path; Git resolves it relative to the repository/workdir. Here `trusted_path("core.hooksPath")` is converted to an owned path and used directly for `.exists()`/`.join()`. If the returned path is relative, hook discovery can depend on the process CWD instead of the repo. Consider normalizing relative paths against `repo.workdir()` (or repo root) before using them.". Also switch get_hooks_dir_gix() to use the same trusted_path mechanism as above, probably this wants to be deduplicated. Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
| pub fn git_remote_branches(ctx: &but_ctx::Context) -> Result<Vec<RemoteRefname>> { | ||
| let repo = ctx.git2_repo.get()?; | ||
| repo.remote_branches() | ||
| let repo = ctx.repo.get()?; | ||
| repo.references()? | ||
| .remote_branches()? | ||
| .filter_map(Result::ok) | ||
| .map(|reference| { | ||
| reference | ||
| .name() | ||
| .to_string() | ||
| .parse() | ||
| .context("failed to parse remote refname") | ||
| }) | ||
| .collect() |
There was a problem hiding this comment.
git_remote_branches() previously excluded symbolic remote HEAD refs (e.g. refs/remotes/origin/HEAD). The new implementation iterates remote_branches() without filtering those out, which can change API output and may confuse callers. Consider filtering out references whose full name ends with /HEAD to match prior behavior (see similar filtering in gitbutler-repo/src/repository_ext.rs).
| # In big parts replaced by other crates. | ||
| "crates/but-fs", # 📄filesystem utilities 👉we should be using `but-db` instead. | ||
| "crates/but-status", # 📄One crate for `create_wd_tree()` which no modern code uses anymore. | ||
| "crates/but-status", # 📄`gix`-backed `create_wd_tree()`; legacy callers still route through `git2` adapters in places. |
There was a problem hiding this comment.
The workspace-members list comment says but-status provides create_wd_tree(), but crates/but-status/src/lib.rs no longer defines that function (it only exposes get_status). Consider updating this comment to reflect the current location/API (e.g. but-core::RepositoryExt::create_wd_tree).
| "crates/but-status", # 📄`gix`-backed `create_wd_tree()`; legacy callers still route through `git2` adapters in places. | |
| "crates/but-status", # 📄`gix`-backed status utilities (e.g. `get_status`); `create_wd_tree()` now lives in `but-core::RepositoryExt`. |
| - checkout execution / worktree materialization | ||
| - index/tree materialization that still requires `git2` (`Index::write_tree*`, `read_tree`, and immediately related adapters) | ||
| - `gitbutler-edit-mode` as a legacy checkout/edit-flow boundary crate until its remaining `git2` checkout/index handoff is isolated or replaced | ||
|
|
||
| Transport strategy remains dual-backend for now (no transport backend rewrite in this effort). | ||
| `create_wd_tree()` itself is already implemented in `gix` via `but-status`; remaining `git2` usage around it should be treated as legacy wrapper/caller cleanup, not as a true `git2` implementation boundary. | ||
|
|
||
| Config reading and config-setting are explicitly in-scope for migration in this plan. They should use the existing `git_config.rs` / `gix`-based config helpers and must not be treated as a valid reason to keep a `git2` boundary. | ||
|
|
||
| Transport strategy remains dual-backend for now, but direct `git2` transport/auth call-sites are in-scope for cleanup where `gix` or existing path-based helpers are sufficient. |
There was a problem hiding this comment.
This plan claims create_wd_tree() is implemented in gix via but-status, but in the current tree but-status no longer contains create_wd_tree (it’s implemented on gix::Repository via but-core::RepositoryExt). Updating this statement would keep the migration plan accurate and reduce confusion for follow-up work.
With this PR merged, it should be much easier for agents to use
gixin their adventures as it's much more dominant in the code we care about.All API boundaries should mostly be
gixthen.Follow-up to #12747 .
Tasks
butedit modeactually leave this to @jonathantanmy2 . Codex made a bit of a mess with VBH as it had to workaround the detached conflicted commit.