restore: restore all files by default

I often (try to) use the command for throwing away all working copy
changes. That currently results in a crash on
`submatches.values_of("paths").unwrap()`. Let's make it revert
everything by default instead, since that seems to be my
intuition. Unlike most VCS's, we have a backup of the working copy and
the user can simply do `jj op undo` if they realized it was a mistake.
This commit is contained in:
Martin von Zweigbergk 2021-01-03 10:37:47 -08:00
parent 0137acd0a8
commit 86b2c6b464

View File

@ -1398,7 +1398,7 @@ fn cmd_restore(
));
}
tree_id = crate::diff_edit::edit_diff(&source_commit.tree(), &destination_commit.tree())?;
} else {
} else if sub_matches.is_present("paths") {
let paths = sub_matches.values_of("paths").unwrap();
let mut tree_builder = repo
.store()
@ -1415,6 +1415,8 @@ fn cmd_restore(
}
}
tree_id = tree_builder.write_tree();
} else {
tree_id = source_commit.tree().id().clone();
}
if &tree_id == destination_commit.tree().id() {
ui.write("Nothing changed.\n");