diff --git a/src/commands/branch.rs b/src/commands/branch.rs index 5c4cf1c8e..afec33e08 100644 --- a/src/commands/branch.rs +++ b/src/commands/branch.rs @@ -328,21 +328,24 @@ fn cmd_branch_list( let formatter = formatter.as_mut(); for (name, branch_target) in all_branches { + let found_non_git_remote = { + let pseudo_remote_count = branch_target.remote_targets.contains_key("git") as usize; + branch_target.remote_targets.len() - pseudo_remote_count > 0 + }; + write!(formatter.labeled("branch"), "{name}")?; if let Some(target) = branch_target.local_target.as_ref() { print_branch_target(formatter, target)?; - } else { + } else if found_non_git_remote { writeln!(formatter, " (deleted)")?; + } else { + writeln!(formatter, " (forgotten)")?; } - let mut found_non_git_remote = false; for (remote, remote_target) in branch_target.remote_targets.iter() { if Some(remote_target) == branch_target.local_target.as_ref() { continue; } - if remote != "git" { - found_non_git_remote = true; - } write!(formatter, " ")?; write!(formatter.labeled("branch"), "@{remote}")?; if let Some(local_target) = branch_target.local_target.as_ref() { diff --git a/tests/test_branch_command.rs b/tests/test_branch_command.rs index 0d653450f..b76793270 100644 --- a/tests/test_branch_command.rs +++ b/tests/test_branch_command.rs @@ -137,7 +137,7 @@ fn test_branch_forget_export() { // TODO: Consider allowing forgetting local-git tracking branches as an option let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list"]); insta::assert_snapshot!(stdout, @r###" - foo (deleted) + foo (forgotten) @git: 65b6b74e0897 (no description set) "###); let stderr = test_env.jj_cmd_failure(&repo_path, &["log", "-r=foo", "--no-graph"]);