From 83c051984ea3140eaf7660257cc2f592a7ae1d38 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Wed, 17 Nov 2021 21:49:27 -0800 Subject: [PATCH] cli: print "Added X files, modified Y files, removed Z files" on all updates I was confused myself why the message was only printed by `jj co` and not e.g. `jj undo`. That probably means that it should always be printed (or never be printed). --- src/commands.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index 0d87cebdd..58f6eff48 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -427,7 +427,15 @@ impl RepoCommandHelper { } } self.repo = tx.commit(); - update_working_copy(ui, &self.repo, &mut self.repo.working_copy_locked()) + let stats = update_working_copy(ui, &self.repo, &mut self.repo.working_copy_locked())?; + if let Some(stats) = &stats { + writeln!( + ui, + "Added {} files, modified {} files, removed {} files", + stats.added_files, stats.updated_files, stats.removed_files + )?; + } + Ok(stats) } } @@ -1383,13 +1391,8 @@ fn cmd_checkout( repo_command.start_transaction(&format!("check out commit {}", new_commit.id().hex())); tx.mut_repo().check_out(ui.settings(), &new_commit); let stats = repo_command.finish_transaction(ui, tx)?; - match stats { - None => ui.write("Already on that commit\n")?, - Some(stats) => writeln!( - ui, - "Added {} files, modified {} files, removed {} files", - stats.added_files, stats.updated_files, stats.removed_files - )?, + if stats.is_none() { + ui.write("Already on that commit\n")?; } Ok(()) }