Allow for reusing the `main`/`master` branch.
Bug: 1416631
Change-Id: I498e54e46c4ce97cb5f7f43f1f484640e74ada44
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4300529
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Joanna Wang <jojwang@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index 0f0b364..fd5c90c 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -4846,8 +4846,13 @@
origin, upstream_branch_ref = Changelist.FetchUpstreamTuple(branch)
if origin == '.':
upstream_branch = scm.GIT.ShortBranchName(upstream_branch_ref)
- parent = scm.GIT.GetBranchConfig(settings.GetRoot(), upstream_branch,
- GERRIT_SQUASH_HASH_CONFIG_KEY)
+
+ # Support the `git merge` and `git pull` workflow.
+ if upstream_branch in ['master', 'main']:
+ parent = cl.GetCommonAncestorWithUpstream()
+ else:
+ parent = scm.GIT.GetBranchConfig(settings.GetRoot(), upstream_branch,
+ GERRIT_SQUASH_HASH_CONFIG_KEY)
if parent:
break
branch = upstream_branch