diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rs index 02b8e1cf89e3f43077be1dbd74bfb5ef3a660c17..20b13e1f8ad1916bce78169e96ea19d90e781f31 100644 --- a/crates/git/src/repository.rs +++ b/crates/git/src/repository.rs @@ -78,6 +78,10 @@ pub struct Upstream { } impl Upstream { + pub fn is_remote(&self) -> bool { + self.remote_name().is_some() + } + pub fn remote_name(&self) -> Option<&str> { self.ref_name .strip_prefix("refs/remotes/") diff --git a/crates/git_ui/src/branch_picker.rs b/crates/git_ui/src/branch_picker.rs index 04c5575d1fd34b9c16236a5d566deed0b7bdc3cc..59a3f3594bf87109fe346c84f31d5f92f85792ae 100644 --- a/crates/git_ui/src/branch_picker.rs +++ b/crates/git_ui/src/branch_picker.rs @@ -98,15 +98,18 @@ impl BranchList { let all_branches = cx .background_spawn(async move { - let upstreams: HashSet<_> = all_branches + let remote_upstreams: HashSet<_> = all_branches .iter() .filter_map(|branch| { - let upstream = branch.upstream.as_ref()?; - Some(upstream.ref_name.clone()) + branch + .upstream + .as_ref() + .filter(|upstream| upstream.is_remote()) + .map(|upstream| upstream.ref_name.clone()) }) .collect(); - all_branches.retain(|branch| !upstreams.contains(&branch.ref_name)); + all_branches.retain(|branch| !remote_upstreams.contains(&branch.ref_name)); all_branches.sort_by_key(|branch| { branch