forked from mirrors/jj
cli: make jj status
show status for the current workspace (#13)
`jj status` shows the status for the default workspace. Make it use the current workspace instead.
This commit is contained in:
parent
3588934fc1
commit
5b46fa3282
1 changed files with 34 additions and 29 deletions
|
@ -2420,13 +2420,16 @@ fn cmd_status(
|
||||||
let mut workspace_command = command.workspace_helper(ui)?;
|
let mut workspace_command = command.workspace_helper(ui)?;
|
||||||
workspace_command.maybe_commit_working_copy(ui)?;
|
workspace_command.maybe_commit_working_copy(ui)?;
|
||||||
let repo = workspace_command.repo();
|
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());
|
||||||
ui.write("Parent commit: ")?;
|
let maybe_checkout = maybe_checkout_id.map(|id| repo.store().get_commit(id).unwrap());
|
||||||
ui.write_commit_summary(repo.as_repo_ref(), &commit.parents()[0])?;
|
if let Some(checkout_commit) = &maybe_checkout {
|
||||||
ui.write("\n")?;
|
ui.write("Parent commit: ")?;
|
||||||
ui.write("Working copy : ")?;
|
ui.write_commit_summary(repo.as_repo_ref(), &checkout_commit.parents()[0])?;
|
||||||
ui.write_commit_summary(repo.as_repo_ref(), &commit)?;
|
ui.write("\n")?;
|
||||||
ui.write("\n")?;
|
ui.write("Working copy : ")?;
|
||||||
|
ui.write_commit_summary(repo.as_repo_ref(), checkout_commit)?;
|
||||||
|
ui.write("\n")?;
|
||||||
|
}
|
||||||
|
|
||||||
let mut conflicted_local_branches = vec![];
|
let mut conflicted_local_branches = vec![];
|
||||||
let mut conflicted_remote_branches = vec![];
|
let mut conflicted_remote_branches = vec![];
|
||||||
|
@ -2475,31 +2478,33 @@ fn cmd_status(
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let parent_tree = commit.parents()[0].tree();
|
if let Some(checkout_commit) = &maybe_checkout {
|
||||||
let tree = commit.tree();
|
let parent_tree = checkout_commit.parents()[0].tree();
|
||||||
if tree.id() == parent_tree.id() {
|
let tree = checkout_commit.tree();
|
||||||
ui.write("The working copy is clean\n")?;
|
if tree.id() == parent_tree.id() {
|
||||||
} else {
|
ui.write("The working copy is clean\n")?;
|
||||||
ui.write("Working copy changes:\n")?;
|
} else {
|
||||||
show_diff_summary(
|
ui.write("Working copy changes:\n")?;
|
||||||
ui,
|
show_diff_summary(
|
||||||
workspace_command.workspace_root(),
|
|
||||||
parent_tree.diff(&tree, &EverythingMatcher),
|
|
||||||
)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
let conflicts = tree.conflicts();
|
|
||||||
if !conflicts.is_empty() {
|
|
||||||
ui.stdout_formatter().add_label("conflict".to_string())?;
|
|
||||||
writeln!(ui, "There are unresolved conflicts at these paths:")?;
|
|
||||||
ui.stdout_formatter().remove_label()?;
|
|
||||||
for (path, _) in conflicts {
|
|
||||||
writeln!(
|
|
||||||
ui,
|
ui,
|
||||||
"{}",
|
workspace_command.workspace_root(),
|
||||||
&ui.format_file_path(workspace_command.workspace_root(), &path)
|
parent_tree.diff(&tree, &EverythingMatcher),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let conflicts = tree.conflicts();
|
||||||
|
if !conflicts.is_empty() {
|
||||||
|
ui.stdout_formatter().add_label("conflict".to_string())?;
|
||||||
|
writeln!(ui, "There are unresolved conflicts at these paths:")?;
|
||||||
|
ui.stdout_formatter().remove_label()?;
|
||||||
|
for (path, _) in conflicts {
|
||||||
|
writeln!(
|
||||||
|
ui,
|
||||||
|
"{}",
|
||||||
|
&ui.format_file_path(workspace_command.workspace_root(), &path)
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue