forked from mirrors/jj
jj abandon
: Print every abandoned commit
This can be disabled with the new `--quiet` option. Printing every commit would give the user all the information of how to undo this or where to `jj restore` from if they realize they need to after the abandon.
This commit is contained in:
parent
ef3071ba09
commit
c0fc9a464a
2 changed files with 22 additions and 7 deletions
|
@ -415,6 +415,9 @@ struct AbandonArgs {
|
|||
/// The revision(s) to abandon
|
||||
#[arg(default_value = "@")]
|
||||
revisions: Vec<RevisionArg>,
|
||||
/// Do not print every abandoned commit on a separate line
|
||||
#[arg(long, short)]
|
||||
summary: bool,
|
||||
/// Ignored (but lets you pass `-r` for consistency with other commands)
|
||||
#[arg(short = 'r', hide = true)]
|
||||
unused_revision: bool,
|
||||
|
@ -2090,9 +2093,9 @@ fn cmd_abandon(
|
|||
}
|
||||
let num_rebased = tx.mut_repo().rebase_descendants(command.settings())?;
|
||||
|
||||
let workspace_id = command.workspace_helper(ui)?.workspace_id();
|
||||
if to_abandon.len() == 1 {
|
||||
ui.write("Abandoned commit ")?;
|
||||
let workspace_id = command.workspace_helper(ui)?.workspace_id();
|
||||
write_commit_summary(
|
||||
ui.stdout_formatter().as_mut(),
|
||||
tx.repo().as_repo_ref(),
|
||||
|
@ -2101,12 +2104,21 @@ fn cmd_abandon(
|
|||
command.settings(),
|
||||
)?;
|
||||
ui.write("\n")?;
|
||||
} else if !args.summary {
|
||||
ui.write("Abandoned the following commits:\n")?;
|
||||
for commit in to_abandon {
|
||||
ui.write(" ")?;
|
||||
write_commit_summary(
|
||||
ui.stdout_formatter().as_mut(),
|
||||
tx.repo().as_repo_ref(),
|
||||
&workspace_id,
|
||||
&commit,
|
||||
command.settings(),
|
||||
)?;
|
||||
ui.write("\n")?;
|
||||
}
|
||||
} else {
|
||||
writeln!(
|
||||
ui,
|
||||
"Abandoned {} commits. This can be undone with `jj undo` or `jj op restore`.",
|
||||
&to_abandon.len()
|
||||
)?;
|
||||
writeln!(ui, "Abandoned {} commits.", &to_abandon.len())?;
|
||||
}
|
||||
if num_rebased > 0 {
|
||||
writeln!(
|
||||
|
|
|
@ -94,7 +94,10 @@ fn test_rebase_branch_with_merge() {
|
|||
test_env.jj_cmd_success(&repo_path, &["undo"]);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["abandon", "descendants(c)"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
Abandoned 3 commits. This can be undone with `jj undo` or `jj op restore`.
|
||||
Abandoned the following commits:
|
||||
5557ece3e631 e
|
||||
b7c62f28ed10 d
|
||||
fe2e8e8b50b3 c
|
||||
Working copy now at: e7bb061217d5 (no description set)
|
||||
Added 0 files, modified 0 files, removed 3 files
|
||||
"###);
|
||||
|
|
Loading…
Reference in a new issue