Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: harden "stg rebase -i" against patches with milti-line subjects #474

Merged
merged 1 commit into from
Jul 20, 2024
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
5 changes: 4 additions & 1 deletion src/cmd/rebase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,10 @@ fn make_instructions_template(stack: &Stack, previously_applied: &[PatchName]) -
let subject = commit
.message()
.map(|message_ref| message_ref.title.to_str_lossy())
.unwrap_or_default();
.unwrap_or_default()
.replace(['\r', '\n'], " ")
.trim()
.to_owned();
writeln!(template, "keep {patchname:name_width$} # {subject}").unwrap();
}
if !found_apply_boundary {
Expand Down
9 changes: 9 additions & 0 deletions t/t2203-rebase-interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,13 @@ test_expect_success 'No patches exits early' '
stg rebase --interactive
'

test_expect_success 'Patches with multi-line subject' '
printf "p0: line 1\nline 2\n" | stg new -f - p0 &&
printf "p1: line 1\nline 2\n" | stg new -f - p1 &&
test_set_editor cat &&
test_when_finished test_set_editor false &&
stg rebase --interactive &&
test "$(stg series --applied -c)" = "2"
'

test_done
Loading