From c889baaabe80517be49c72e400c75b43d164598d Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sat, 24 Jul 2021 10:30:47 -0700 Subject: [PATCH] cli: make `jj describe` not rewrite commit if description was unchanged --- src/commands.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index 25af6c536..63cde1acf 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1536,11 +1536,16 @@ fn cmd_describe( } else { description = edit_description(repo, commit.description()); } - let mut tx = repo_command.start_transaction(&format!("describe commit {}", commit.id().hex())); - CommitBuilder::for_rewrite_from(ui.settings(), repo.store(), &commit) - .set_description(description) - .write_to_repo(tx.mut_repo()); - repo_command.finish_transaction(ui, tx)?; + if description == *commit.description() { + ui.write("Nothing changed.\n")?; + } else { + let mut tx = + repo_command.start_transaction(&format!("describe commit {}", commit.id().hex())); + CommitBuilder::for_rewrite_from(ui.settings(), repo.store(), &commit) + .set_description(description) + .write_to_repo(tx.mut_repo()); + repo_command.finish_transaction(ui, tx)?; + } Ok(()) }