branches: Fix "not in" handling
If the branch is current, or present in less than half of the projects,
list which projects it is *in*.
Otherwise, correctly detect which projects (by relpath) it is not in.
Previously, the "not in" path would incorrectly list all projects.
Change-Id: Ia153856f577035a51f538b7bf5d3135b70c69d52
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/328199
Tested-by: LaMont Jones <lamontjones@google.com>
Reviewed-by: Xin Li <delphij@google.com>
diff --git a/subcmds/branches.py b/subcmds/branches.py
index 6d975ed..7b5decc 100644
--- a/subcmds/branches.py
+++ b/subcmds/branches.py
@@ -151,7 +151,7 @@
fmt = out.write
paths = []
non_cur_paths = []
- if i.IsSplitCurrent or (in_cnt < project_cnt - in_cnt):
+ if i.IsSplitCurrent or (in_cnt <= project_cnt - in_cnt):
in_type = 'in'
for b in i.projects:
if not i.IsSplitCurrent or b.current:
@@ -163,9 +163,9 @@
in_type = 'not in'
have = set()
for b in i.projects:
- have.add(b.project)
+ have.add(b.project.relpath)
for p in projects:
- if p not in have:
+ if p.relpath not in have:
paths.append(p.relpath)
s = ' %s %s' % (in_type, ', '.join(paths))