From 80a05427ae9c1c0eb718e3852bd9fa2235a9fdce Mon Sep 17 00:00:00 2001
From: Haibo Huang <hhb@google.com>
Date: Mon, 27 Aug 2018 13:49:42 -0700
Subject: [PATCH] [Updater] Ignore commits brought in by a merge

As an example, if there is commit C (300 days old) in dev branch. Later dev is merged into upstream-master as commit M (2 days old).

Before this change, the updater will say "2 commits (300 days) behind" because both C and M is not in master.

After this change, it will say "1 commit (2 days) behind", which makes more sense.

(This change raises error when there's no merge base between upstream and master. But I think it is expected)

Test: updater.sh check googletest
Change-Id: I963b378e61677c1f6ea13af0d0f558846040b840
---
 git_utils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git_utils.py b/git_utils.py
index 5743b8f..b2f6bbb 100644
--- a/git_utils.py
+++ b/git_utils.py
@@ -60,7 +60,7 @@ def list_remotes(proj_path):
 
 def get_commits_ahead(proj_path, branch, base_branch):
     """Lists commits in `branch` but not `base_branch`."""
-    out = _run(['git', 'rev-list', '--left-only',
+    out = _run(['git', 'rev-list', '--left-only', '--ancestry-path',
                 '{}...{}'.format(branch, base_branch)],
                proj_path)
     return out.stdout.decode('utf-8').splitlines()
-- 
GitLab