cli: make `jj status` show status for the current workspace
`jj status` shows the status for the default workspace. Make it use
the current workspace instead.
@@ -2420,13 +2420,16 @@ fn cmd_status(
let mut workspace_command = command.workspace_helper(ui)?;
workspace_command.maybe_commit_working_copy(ui)?;
let repo = workspace_command.repo();
- let commit = repo.store().get_commit(repo.view().checkout()).unwrap();
+ let maybe_checkout_id = repo.view().get_checkout(&workspace_command.workspace_id());
+ let maybe_checkout = maybe_checkout_id.map(|id| repo.store().get_commit(id).unwrap());
+ if let Some(checkout_commit) = &maybe_checkout {
ui.write("Parent commit: ")?;
- ui.write_commit_summary(repo.as_repo_ref(), &commit.parents()[0])?;
+ ui.write_commit_summary(repo.as_repo_ref(), &checkout_commit.parents()[0])?;
ui.write("\n")?;
ui.write("Working copy : ")?;
- ui.write_commit_summary(repo.as_repo_ref(), &commit)?;
+ ui.write_commit_summary(repo.as_repo_ref(), checkout_commit)?;
ui.write("\n")?;
+ }
let mut conflicted_local_branches = vec![];
let mut conflicted_remote_branches = vec![];
@@ -2475,8 +2478,9 @@ fn cmd_status(
)?;
}
- let parent_tree = commit.parents()[0].tree();
- let tree = commit.tree();
+ if let Some(checkout_commit) = &maybe_checkout {
+ let parent_tree = checkout_commit.parents()[0].tree();
+ let tree = checkout_commit.tree();
if tree.id() == parent_tree.id() {
ui.write("The working copy is clean\n")?;
} else {
@@ -2501,6 +2505,7 @@ fn cmd_status(
)?;
}
}
+ }
Ok(())
}
