diff --git a/CHANGELOG.md b/CHANGELOG.md index 96ae032619..878a8fceb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). * `jj workspace forget` now abandons the workspace's working-copy commit if it was empty. +* `jj backout` now includes the backed out commit's subject in the new commit + message. + ### Fixed bugs ## [0.19.0] - 2024-07-03 @@ -178,7 +181,6 @@ Thanks to the people who made this release happen! were global flags and specifying them once would insert the new commit before/ after all the specified commits. - ### Deprecations * Attempting to alias a built-in command now gives a warning, rather than being diff --git a/cli/src/commands/backout.rs b/cli/src/commands/backout.rs index ba74d8546f..9562b808d1 100644 --- a/cli/src/commands/backout.rs +++ b/cli/src/commands/backout.rs @@ -47,6 +47,16 @@ pub(crate) fn cmd_backout( parents.push(destination); } let mut tx = workspace_command.start_transaction(); + let commit_to_back_out_subject = commit_to_back_out + .description() + .lines() + .next() + .unwrap_or_default(); + let new_commit_description = format!( + "Back out \"{}\"\n\nThis backs out commit {}.\n", + commit_to_back_out_subject, + &commit_to_back_out.id().hex() + ); let old_base_tree = commit_to_back_out.parent_tree(tx.mut_repo())?; let new_base_tree = merge_commit_trees(tx.mut_repo(), &parents)?; let old_tree = commit_to_back_out.tree()?; @@ -54,10 +64,7 @@ pub(crate) fn cmd_backout( let new_parent_ids = parents.iter().map(|commit| commit.id().clone()).collect(); tx.mut_repo() .new_commit(command.settings(), new_parent_ids, new_tree.id()) - .set_description(format!( - "backout of commit {}", - &commit_to_back_out.id().hex() - )) + .set_description(new_commit_description) .write()?; tx.finish( ui, diff --git a/cli/tests/test_backout_command.rs b/cli/tests/test_backout_command.rs index bc4f74678d..6d0aa53e14 100644 --- a/cli/tests/test_backout_command.rs +++ b/cli/tests/test_backout_command.rs @@ -50,7 +50,9 @@ fn test_backout() { insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @""); insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" - ◉ 8fe4e9345020 backout of commit 2443ea76b0b1c531326908326aab7020abab8e6c + ◉ 6d845ed9fb6a Back out "a" + │ + │ This backs out commit 2443ea76b0b1c531326908326aab7020abab8e6c. @ 2443ea76b0b1 a ◉ 000000000000 "###); @@ -65,8 +67,12 @@ fn test_backout() { insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @""); insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" - ◉ 46f192066e5e backout of commit 8fe4e93450209a70a6b9cd9af612e86634fd31fd - @ 8fe4e9345020 backout of commit 2443ea76b0b1c531326908326aab7020abab8e6c + ◉ 79555ea9040b Back out "Back out "a"" + │ + │ This backs out commit 6d845ed9fb6a3d367e2d7068ef0256b1a10705a9. + @ 6d845ed9fb6a Back out "a" + │ + │ This backs out commit 2443ea76b0b1c531326908326aab7020abab8e6c. ◉ 2443ea76b0b1 a ◉ 000000000000 "###);