ok/jj
1
0
Fork 0
forked from mirrors/jj

cli: print "Added X files, ..." message only if any files changed

Looking at the impact on the smoke test and the tutorial, I think I
went overboard in 83c0519. Let's only print the message if any files
changed.
This commit is contained in:
Martin von Zweigbergk 2021-11-19 23:03:25 -08:00
parent ad6b6f516d
commit d34060f013
3 changed files with 11 additions and 8 deletions

View file

@ -16,6 +16,7 @@ Let's start by cloning the Jujutsu Git repo using `jj`:
$ jj git clone https://github.com/martinvonz/jj.git $ jj git clone https://github.com/martinvonz/jj.git
Fetching into new repo in "<dir>/jj" Fetching into new repo in "<dir>/jj"
Working copy now at: 265ecf5cab2d Working copy now at: 265ecf5cab2d
Added 98 files, modified 0 files, removed 0 files
$ cd jj $ cd jj
``` ```
@ -34,7 +35,7 @@ Let's check out a particular commit, so we get more predicable output:
```shell script ```shell script
$ jj co 080a9b37ff7e $ jj co 080a9b37ff7e
Working copy now at: 608c179a60df Working copy now at: 608c179a60df
Added 2 files, modified 57 files, removed 5 files Added 7 files, modified 65 files, removed 21 files
$ jj st $ jj st
Parent commit: 080a9b37ff7e cli: make `jj st` show parent commit before working copy commit Parent commit: 080a9b37ff7e cli: make `jj st` show parent commit before working copy commit
Working copy : 608c179a60df Working copy : 608c179a60df
@ -226,6 +227,7 @@ modifies a different file. Let's now rebase B2 directly onto A:
$ jj rebase -s 5548374c0794 -d cf49e6bec410 $ jj rebase -s 5548374c0794 -d cf49e6bec410
Rebased 3 commits Rebased 3 commits
Working copy now at: 9195b6d2e8dc Working copy now at: 9195b6d2e8dc
Added 0 files, modified 1 files, removed 0 files
$ jj l $ jj l
@ 9195b6d2e8dc 47684978bf4b martinvonz@google.com 2021-05-26 12:39:56.000 -07:00 conflict @ 9195b6d2e8dc 47684978bf4b martinvonz@google.com 2021-05-26 12:39:56.000 -07:00 conflict
| |
@ -411,6 +413,7 @@ $ jj edit -r ::@
Created 2423c134ea70 ABC Created 2423c134ea70 ABC
Rebased 2 descendant commits Rebased 2 descendant commits
Working copy now at: d31c52e8ca41 Working copy now at: d31c52e8ca41
Added 0 files, modified 1 files, removed 0 files
``` ```
When Meld starts, edit the right side by e.g. adding something to the first When Meld starts, edit the right side by e.g. adding something to the first
line. Then close Meld. You can now inspect the rewritten commit with line. Then close Meld. You can now inspect the rewritten commit with

View file

@ -429,11 +429,13 @@ impl RepoCommandHelper {
self.repo = tx.commit(); self.repo = tx.commit();
let stats = 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 { if let Some(stats) = &stats {
writeln!( if stats.added_files > 0 || stats.updated_files > 0 || stats.removed_files > 0 {
ui, writeln!(
"Added {} files, modified {} files, removed {} files", ui,
stats.added_files, stats.updated_files, stats.removed_files "Added {} files, modified {} files, removed {} files",
)?; stats.added_files, stats.updated_files, stats.removed_files
)?;
}
} }
Ok(stats) Ok(stats)
} }

View file

@ -92,7 +92,6 @@ $",
let stdout_string = output.stdout_string(); let stdout_string = output.stdout_string();
let output_regex = Regex::new( let output_regex = Regex::new(
"^Working copy now at: [[:xdigit:]]+ add some files "^Working copy now at: [[:xdigit:]]+ add some files
Added 0 files, modified 0 files, removed 0 files
$", $",
) )
.unwrap(); .unwrap();
@ -108,7 +107,6 @@ $",
let stdout_string = output.stdout_string(); let stdout_string = output.stdout_string();
let output_regex = Regex::new( let output_regex = Regex::new(
"^Working copy now at: [[:xdigit:]]+ "^Working copy now at: [[:xdigit:]]+
Added 0 files, modified 0 files, removed 0 files
$", $",
) )
.unwrap(); .unwrap();