From 74c53b62227b8f4b94bf35af5876b2538b86ee30 Mon Sep 17 00:00:00 2001 From: Joanna Wang Date: Wed, 1 Mar 2023 22:00:22 +0000 Subject: [PATCH] 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 Commit-Queue: Joanna Wang --- git_cl.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/git_cl.py b/git_cl.py index 0f0b36417..fd5c90cf3 100755 --- a/git_cl.py +++ b/git_cl.py @@ -4846,8 +4846,13 @@ def UploadAllSquashed(options, orig_args): 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