Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/git/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,26 @@ impl GitCommands {
.run_expecting_success()?;
Ok(())
}

pub fn continue_cherry_pick(&self) -> Result<()> {
self.git()
.args(&["cherry-pick", "--continue"])
.env("GIT_EDITOR", "true")
.run_expecting_success()?;
Ok(())
}

pub fn abort_cherry_pick(&self) -> Result<()> {
self.git()
.args(&["cherry-pick", "--abort"])
.run_expecting_success()?;
Ok(())
}

pub fn skip_cherry_pick(&self) -> Result<()> {
self.git()
.args(&["cherry-pick", "--skip"])
.run_expecting_success()?;
Ok(())
}
}
11 changes: 10 additions & 1 deletion src/gui/controller/commits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ pub fn handle_key(gui: &mut Gui, key: KeyEvent, keybindings: &KeybindingConfig)
return paste_commits(gui);
}

if matches_key(key, &keybindings.commits.reset_cherry_pick) {
gui.cherry_pick_clipboard.clear();
return Ok(());
}

if matches_key(key, &keybindings.commits.squash_above_commits) {
return squash_above_commits_menu(gui);
}
Expand Down Expand Up @@ -300,7 +305,11 @@ fn paste_commits(gui: &mut Gui) -> Result<()> {
}

let n = gui.cherry_pick_clipboard.len();
let hashes = gui.cherry_pick_clipboard.clone();
let mut hashes = gui.cherry_pick_clipboard.clone();
// The clipboard stores commits newest-first (matching the visual list order).
// git cherry-pick applies commits in argument order, so we must reverse to
// apply oldest-first and preserve the intended history.
hashes.reverse();

gui.popup = PopupState::Confirm {
title: "Cherry-pick".to_string(),
Expand Down
38 changes: 36 additions & 2 deletions src/gui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3538,7 +3538,7 @@ impl Gui {
&mut self,
is_rebasing: bool,
is_merging: bool,
_is_cherry_picking: bool,
is_cherry_picking: bool,
) -> Result<()> {
let mut items = Vec::new();

Expand Down Expand Up @@ -3588,8 +3588,42 @@ impl Gui {
});
}

if is_cherry_picking {
items.push(popup::MenuItem {
label: "Continue cherry-pick".to_string(),
description: "git cherry-pick --continue".to_string(),
key: Some("c".to_string()),
action: Some(Box::new(|gui| {
gui.git.continue_cherry_pick()?;
gui.needs_refresh = true;
Ok(())
})),
});
items.push(popup::MenuItem {
label: "Abort cherry-pick".to_string(),
description: "git cherry-pick --abort".to_string(),
key: Some("a".to_string()),
action: Some(Box::new(|gui| {
gui.git.abort_cherry_pick()?;
gui.cherry_pick_clipboard.clear();
gui.needs_refresh = true;
Ok(())
})),
});
items.push(popup::MenuItem {
label: "Skip this commit".to_string(),
description: "git cherry-pick --skip".to_string(),
key: Some("s".to_string()),
action: Some(Box::new(|gui| {
gui.git.skip_cherry_pick()?;
gui.needs_refresh = true;
Ok(())
})),
});
}

self.popup = PopupState::Menu {
title: "Rebase/Merge options".to_string(),
title: "Rebase/Merge/Cherry-pick options".to_string(),
items,
selected: 0,
loading_index: None,
Expand Down
Loading