cli: filter out synced remote branches early

Perhaps, this make it a bit clearer when "deleted" local branches should be
displayed. In practice, this change is noop since remote_ref.target should
never be absent.
This commit is contained in:
Yuya Nishihara 2024-04-29 23:00:55 +09:00
parent 8e4f75552d
commit af9f9ba1e4

View file

@ -694,6 +694,9 @@ fn cmd_branch_list(
if args.tracked {
tracking_remote_refs
.retain(|&(remote, _)| remote != git::REMOTE_NAME_FOR_LOCAL_GIT_REPO);
} else if !args.all_remotes {
tracking_remote_refs
.retain(|&(_, remote_ref)| remote_ref.target != *branch_target.local_target);
}
if !args.tracked && branch_target.local_target.is_present()
@ -709,10 +712,6 @@ fn cmd_branch_list(
for &(remote, remote_ref) in &tracking_remote_refs {
let synced = remote_ref.target == *branch_target.local_target;
if !args.all_remotes && !args.tracked && synced {
continue;
}
write!(formatter, " ")?;
write!(formatter.labeled("branch"), "@{remote}")?;
let local_target = branch_target.local_target;