From 3c2657c393c8d072a388c7a7384dc8881fee7989 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sun, 25 Jun 2023 20:15:44 +0900 Subject: [PATCH] cli: add hint for git-exporting forgotten branches Inspired by d01ecc5c4604 "more detailed message describing deleted branches." And yes, "jj git export" does propagate "jj branch forget" to the underlying Git repository, which strengthen my feeling that git::export_refs() should also remove "forgotten" remote tracking refs. --- src/commands/branch.rs | 21 +++++++++++++++------ tests/test_branch_command.rs | 1 + 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/commands/branch.rs b/src/commands/branch.rs index afec33e08..3006ba39c 100644 --- a/src/commands/branch.rs +++ b/src/commands/branch.rs @@ -369,12 +369,21 @@ fn cmd_branch_list( } print_branch_target(formatter, remote_target)?; } - if found_non_git_remote && branch_target.local_target.is_none() { - writeln!( - formatter, - " (this branch will be *deleted permanently* on the remote on the\n next `jj \ - git push`. Use `jj branch forget` to prevent this)" - )?; + + if branch_target.local_target.is_none() { + if found_non_git_remote { + writeln!( + formatter, + " (this branch will be *deleted permanently* on the remote on the\n next \ + `jj git push`. Use `jj branch forget` to prevent this)" + )?; + } else { + writeln!( + formatter, + " (this branch will be deleted from the underlying Git repo on the next `jj \ + git export`)" + )?; + } } } diff --git a/tests/test_branch_command.rs b/tests/test_branch_command.rs index b76793270..28a2ed5ca 100644 --- a/tests/test_branch_command.rs +++ b/tests/test_branch_command.rs @@ -139,6 +139,7 @@ fn test_branch_forget_export() { insta::assert_snapshot!(stdout, @r###" foo (forgotten) @git: 65b6b74e0897 (no description set) + (this branch will be deleted from the underlying Git repo on the next `jj git export`) "###); let stderr = test_env.jj_cmd_failure(&repo_path, &["log", "-r=foo", "--no-graph"]); insta::assert_snapshot!(stderr, @r###"