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
10 changes: 5 additions & 5 deletions src/cmd/rebase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ fn run(matches: &ArgMatches) -> Result<()> {
let allow_push_conflicts = argset::resolve_allow_push_conflicts(&config, matches);
let committer_date_is_author_date = matches.get_flag("committer-date-is-author-date");
let interactive = matches.get_flag("interactive");
let exec_cmds: Vec<&str> = matches
.get_many::<String>("exec")
.map(|vals| vals.map(String::as_str).collect())
.unwrap_or_default();

let target_commit = if let Some(target_rev_spec) =
matches.get_one::<SingleRevisionSpec>("committish")
Expand Down Expand Up @@ -149,7 +153,7 @@ fn run(matches: &ArgMatches) -> Result<()> {
));
};

if !interactive && target_commit.id == stack.base().id {
if !interactive && exec_cmds.is_empty() && target_commit.id == stack.base().id {
print_info_message(
matches,
&format!(
Expand Down Expand Up @@ -259,10 +263,6 @@ fn run(matches: &ArgMatches) -> Result<()> {
} else if !matches.get_flag("nopush") {
stack.check_head_top_mismatch()?;
let check_merged = matches.get_flag("merged");
let exec_cmds: Vec<&str> = matches
.get_many::<String>("exec")
.map(|vals| vals.map(String::as_str).collect())
.unwrap_or_default();

stack
.setup_transaction()
Expand Down
7 changes: 7 additions & 0 deletions t/t2206-rebase-exec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ test_expect_success 'Rebase with --exec runs command after each patch' '
test $(wc -l <exec.log) = 3
'

test_expect_success 'Rebase on {base} with --exec runs command after each patch' '
rm -f exec.log &&
stg rebase --exec "echo EXEC >>exec.log" {base} &&
test $(stg series --applied -c) = 3 &&
test $(wc -l <exec.log) = 3
'

test_expect_success 'Rebase with multiple --exec options' '
rm -f exec.log exec2.log &&
stg rebase --exec "echo EXEC1 >>exec.log" --exec "echo EXEC2 >>exec2.log" master~1 &&
Expand Down