Skip to content

revive but worktree subcommands#14189

Closed
krlvi wants to merge 2 commits into
masterfrom
revive-worktree-command
Closed

revive but worktree subcommands#14189
krlvi wants to merge 2 commits into
masterfrom
revive-worktree-command

Conversation

@krlvi

@krlvi krlvi commented Jun 11, 2026

Copy link
Copy Markdown
Member

@estib-vega @Caleb-T-Owens - this may not be the final form of this, but with this change the worktree stuff seems to be alive once again.

Copilot AI review requested due to automatic review settings June 11, 2026 18:06
@github-actions github-actions Bot added rust Pull requests that update Rust code CLI The command-line program `but` labels Jun 11, 2026
@krlvi krlvi enabled auto-merge June 11, 2026 18:07

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d187730672

ℹ️ 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".

Comment thread crates/but/src/lib.rs
command::legacy::worktree::handle(cmd, &mut ctx, out)
.emit_metrics(metrics_ctx)
.show_root_cause_error_then_exit_without_destructors(output)
.map_err(CliError::from)

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.

P2 Badge Update the bundled CLI skill for worktree

crates/but/AGENTS.md requires updating crates/but/skill/ after CLI command or workflow changes. This commit revives the but worktree CLI path here, but rg "worktree" crates/but/skill still returns no coverage, so bundled agents will keep stale CLI guidance and miss the revived worktree workflow.

Useful? React with 👍 / 👎.

Copilot AI left a comment

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.

Pull request overview

This PR revives the legacy but worktree CLI subcommands by reworking the but-worktrees crate into more “plumbing-style” APIs (taking gix::Repository/but_graph::Workspace inputs instead of a full but_ctx::Context), updating the legacy CLI command wiring, and adding integration/destroy behavior around auto-created worktree branches.

Changes:

  • Reintroduced/covered but worktree new/list/integrate/destroy via legacy CLI routing and new end-to-end CLI tests.
  • Refactored but-worktrees APIs (new/list/destroy/integrate) to operate on Repository + Workspace (+ metadata) and switched integration to the graph rebase editor flow, adding NothingToIntegrate.
  • Ensured cleanup of auto-created refs/heads/gitbutler/worktree/<id> branches on destroy/integrate; improved serde support for worktree IDs/fields.

Reviewed changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/but/tests/but/command/worktree.rs Adds CLI-level journey + destroy + “nothing to integrate” tests for legacy but worktree.
crates/but/tests/but/command/mod.rs Includes the new legacy worktree test module behind the legacy feature.
crates/but/src/lib.rs Wires legacy Worktree subcommand to return CliError like other subcommands.
crates/but/src/command/legacy/worktree.rs Adds human output for NothingToIntegrate during integrate --dry.
crates/but-api/src/legacy/worktree.rs Adapts legacy API endpoints to the refactored but-worktrees plumbing signatures.
crates/but-worktrees/src/new.rs Refactors worktree creation to take repo/ws/data_dir and uses the shared branch namespace constant.
crates/but-worktrees/src/list.rs Refactors list to accept &gix::Repository.
crates/but-worktrees/src/destroy.rs Refactors destroy to accept &gix::Repository and deletes auto-created worktree branches.
crates/but-worktrees/src/integrate.rs Moves integration to graph editor/rebase; adds NothingToIntegrate status and working-dir conflict prediction.
crates/but-worktrees/src/git.rs Improves git worktree command logging, fixes remove error message, and adds delete_worktree_branch().
crates/but-worktrees/src/lib.rs Adds WORKTREE_BRANCH_NAMESPACE and updates serde handling for worktree ID/ref/base fields.
crates/but-worktrees/tests/worktree/*.rs Updates tests to use new util plumbing and adds coverage for “fresh worktree doesn’t obscure branch”.
crates/but-worktrees/Cargo.toml Updates dependencies (adds but-graph, but-serde, moves but-ctx to dev-deps).
crates/but-serde/src/lib.rs Adds deserialize() for bstring_lossy to support #[serde(with = ...)] on WorktreeId.
Cargo.lock Locks dependency graph updates from the above crate changes.

Comment on lines 26 to 28
if !ws.refname_is_segment(refname) {
bail!("Branch not found in workspace");
}
Comment on lines 35 to 39
Integratable {
/// The cherry pick produced when integrating will be conflicted.
cherry_pick_conflicts: bool,
/// Commits above where this worktree will be cherry-picked are going to
/// end up conflicted.
krlvi added 2 commits June 11, 2026 20:46
Branches auto-created for GitButler-managed worktrees
(refs/heads/gitbutler/worktree/*) point at the same commit as their
source branch until work happens in the worktree. They participated in
segment-name disambiguation, where two metadata-less branches on one
commit yield no name at all: the source branch lost its segment boundary
and vanished from the workspace, breaking status, worktree new, and
integrate for that branch.

Exclude the namespace from naming, consistent with the projection
already treating gitbutler/* refs as implementation details. This hunk
was part of the original branch but got lost in the squash, which is
why fresh_worktree_does_not_obscure_its_branch was failing in CI.
@krlvi krlvi force-pushed the revive-worktree-command branch from d187730 to 8f549b2 Compare June 11, 2026 19:14
@krlvi krlvi closed this Jun 13, 2026
auto-merge was automatically disabled June 13, 2026 08:08

Pull request was closed

@krlvi

krlvi commented Jun 13, 2026

Copy link
Copy Markdown
Member Author

replaced by #14213

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLI The command-line program `but` rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants