From 7931b377deea3e53de0ad3252e54d04da3bafa62 Mon Sep 17 00:00:00 2001 From: Forge Date: Sun, 26 Apr 2026 21:52:08 +0000 Subject: [PATCH 1/2] feat(stashes): add Branch button to stash panel rows Adds a GitBranch icon button to each stash entry row in the StashesPanel, allowing users to create a branch from a stash directly without needing the sidebar right-click context menu. The button opens the existing StashBranchDialog via the workspace's dialogs reference. --- crates/rgitui_workspace/src/stashes_panel.rs | 34 ++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/crates/rgitui_workspace/src/stashes_panel.rs b/crates/rgitui_workspace/src/stashes_panel.rs index 640836a..8b737fc 100644 --- a/crates/rgitui_workspace/src/stashes_panel.rs +++ b/crates/rgitui_workspace/src/stashes_panel.rs @@ -86,6 +86,18 @@ impl StashesPanel { }); }); } + + /// Open the branch-from-stash dialog for the given stash entry. + fn branch_stash(&self, index: usize, cx: &mut Context) { + let Some(ws) = self.workspace.upgrade() else { + return; + }; + ws.update(cx, |ws, cx| { + ws.dialogs.stash_branch_dialog.update(cx, |d, cx| { + d.show_visible(index, cx); + }); + }); + } } impl Render for StashesPanel { @@ -306,6 +318,28 @@ impl StashesPanel { ); } + // Branch + { + let w = weak.clone(); + item = item.child( + IconButton::new( + ElementId::NamedInteger("branch-stash".into(), i as u64), + IconName::GitBranch, + ) + .size(btn_size) + .style(btn_style) + .color(Color::Default) + .tooltip("Create branch from stash") + .on_click( + move |_: &ClickEvent, _: &mut Window, cx: &mut App| { + let _ = w.update(cx, |this: &mut StashesPanel, cx| { + this.branch_stash(idx, cx); + }); + }, + ), + ); + } + // Drop { let w = weak.clone(); From 40fdd861ac7d3bb4e03e276ebfacdd690a6ffce1 Mon Sep 17 00:00:00 2001 From: Forge Date: Mon, 27 Apr 2026 02:05:57 +0000 Subject: [PATCH 2/2] test(stashes): add oid field difference coverage for StashEntry PartialEq --- crates/rgitui_workspace/src/stashes_panel.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/rgitui_workspace/src/stashes_panel.rs b/crates/rgitui_workspace/src/stashes_panel.rs index 8b737fc..862b20f 100644 --- a/crates/rgitui_workspace/src/stashes_panel.rs +++ b/crates/rgitui_workspace/src/stashes_panel.rs @@ -422,6 +422,22 @@ mod tests { assert_ne!(e0, e1); } + #[test] + fn stash_entry_oid_different() { + let e0 = StashEntry { + index: 0, + message: "stash 0".into(), + oid: git2::Oid::zero(), + }; + let e1 = StashEntry { + index: 0, + message: "stash 0".into(), + oid: git2::Oid::from_str("a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2").unwrap(), + }; + assert_ne!(e0.oid, e1.oid); + assert_ne!(e0, e1); + } + #[test] fn stash_entry_debug() { let entry = StashEntry {