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

cli: when updating onto new commit from jj new, use right workspace (#13)

`jj new` will update onto the new commit if the previous commit was
the current checkout. That code needs to use the current workspace's
checkout.
This commit is contained in:
Martin von Zweigbergk 2022-01-30 23:11:53 -08:00
parent ee641bf7ad
commit 3588934fc1

View file

@ -2854,8 +2854,9 @@ fn cmd_new(ui: &mut Ui, command: &CommandHelper, args: &ArgMatches) -> Result<()
let mut tx = workspace_command.start_transaction("new empty commit");
let mut_repo = tx.mut_repo();
let new_commit = commit_builder.write_to_repo(mut_repo);
if mut_repo.view().checkout() == parent.id() {
mut_repo.check_out(workspace_command.workspace_id(), ui.settings(), &new_commit);
let workspace_id = workspace_command.workspace_id();
if mut_repo.view().get_checkout(&workspace_id) == Some(parent.id()) {
mut_repo.check_out(workspace_id, ui.settings(), &new_commit);
}
workspace_command.finish_transaction(ui, tx)?;
Ok(())