ok/jj
1
0
Fork 0
forked from mirrors/jj

cli: do not list non-tracking remote branches by default

I personally don't mind if "jj branch list" showed all non-tracking branches,
but I agree it would be a mess if ~500 remote branches were listed. So let's
hide them by default as non-tracking branches aren't so interesting.

Closes #1136
This commit is contained in:
Yuya Nishihara 2023-10-18 15:56:02 +09:00
parent 12b879dc8f
commit d92be6635c
3 changed files with 14 additions and 9 deletions

View file

@ -38,6 +38,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
See [automatic local branch creation](docs/config.md#automatic-local-branch-creation)
for details.
* Non-tracking remote branches aren't listed by default. Use `jj branch list
--all` to show all local and remote branches.
* It's not allowed to push branches if non-tracking remote branches of the same
name exist.

View file

@ -65,9 +65,10 @@ pub struct BranchDeleteArgs {
/// List branches and their targets
///
/// By default, a tracking remote branch will be included only if its target is
/// different from the local target. For a conflicted branch (both local and
/// remote), old target revisions are preceded by a "-" and new target revisions
/// are preceded by a "+".
/// different from the local target. A non-tracking remote branch won't be
/// listed. For a conflicted branch (both local and remote), old target
/// revisions are preceded by a "-" and new target revisions are preceded by a
/// "+".
///
/// For information about branches, see
/// https://github.com/martinvonz/jj/blob/main/docs/branches.md.
@ -573,10 +574,11 @@ fn cmd_branch_list(
}
}
// TODO: hide non-tracking remotes by default?
for &(remote, remote_ref) in &untracked_remote_refs {
write!(formatter.labeled("branch"), "{name}@{remote}")?;
print_branch_target(formatter, &remote_ref.target)?;
if args.all {
for &(remote, remote_ref) in &untracked_remote_refs {
write!(formatter.labeled("branch"), "{name}@{remote}")?;
print_branch_target(formatter, &remote_ref.target)?;
}
}
}

View file

@ -756,7 +756,8 @@ fn test_branch_list() {
&["branch", "set", "--allow-backwards", "remote-unsync"],
);
// Synchronized tracking remotes aren't listed by default
// Synchronized tracking remotes and non-tracking remotes aren't listed by
// default
insta::assert_snapshot!(
test_env.jj_cmd_success(&local_path, &["branch", "list"]), @r###"
local-only: wqnwkozp 4e887f78 (empty) local-only
@ -767,7 +768,6 @@ fn test_branch_list() {
remote-sync: zwtyzrop c761c7ea (empty) remote-sync
remote-unsync: wqnwkozp 4e887f78 (empty) local-only
@origin (ahead by 1 commits, behind by 1 commits): qpsqxpyq 38ef8af7 (empty) remote-unsync
remote-untrack@origin: vmortlor 71a16b05 (empty) remote-untrack
"###);
insta::assert_snapshot!(