]> git.wh0rd.org Git - home.git/commitdiff
git-rb-catchup: fix merge counts
authorMike Frysinger <vapier@gentoo.org>
Sun, 28 Mar 2021 16:07:45 +0000 (12:07 -0400)
committerMike Frysinger <vapier@gentoo.org>
Sun, 28 Mar 2021 16:07:45 +0000 (12:07 -0400)
.bin/git-rb-catchup

index 2cc5c5381616d3e91c45d10c3350b65d3709dc96..66b87a829ac2b61397f216d9be4c845d7dc6843d 100755 (executable)
@@ -97,7 +97,8 @@ def rebase_bisect(lbranch: str,
 def get_ahead_behind(lbranch: str, rbranch: str) -> Tuple[int, int]:
     """Return number of commits |lbranch| is ahead & behind relative to |rbranch|."""
     output = git(
-        ['rev-list', '--left-right', '--count', f'{lbranch}...{rbranch}']).stdout
+        ['rev-list', '--first-parent', '--left-right', '--count',
+         f'{lbranch}...{rbranch}']).stdout
     return [int(x) for x in output.split()]
 
 
@@ -150,7 +151,7 @@ def main(argv: List[str]) -> int:
     opts = parser.parse_args(argv)
 
     lbranch = get_local_branch()
-    print(f'Local branch resolved to "{lbranch}"')
+    print(f'Local branch resolved to "{lbranch}".')
     if not lbranch:
         print('Unable to resolve local branch', file=sys.stderr)
         return 1
@@ -159,10 +160,11 @@ def main(argv: List[str]) -> int:
         rbranch = opts.branch
     else:
         rbranch = get_tracking_branch(lbranch)
-    print(f'Tracking branch resolved to "{rbranch}"')
+    print(f'Tracking branch resolved to "{rbranch}".')
 
     ahead, behind = get_ahead_behind(lbranch, rbranch)
-    print(f'Branch is {ahead} commits ahead and {behind} commits behind')
+    print(f'Branch is {ahead} commits ahead and {behind} commits behind.')
+    print('NB: Counts for the first parent in merge history, not all commits.')
 
     if not behind:
         print('Up-to-date!')