From 1f891541d2b380127ec84546b1fa8b25ec7a6268 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 24 Feb 2023 15:46:44 +0100 Subject: [PATCH] Fix make_update switching branches with multiple upstreams If repository has multiple remotes with the same name of branch checking out to the branch using simple `git checkout branch` exists with an error: this is because there is ambiguity w.r.t which remote to track. Now the code explicitly provides remote to track, preferring to use "origin" first (which is to be used for Blender style of workflow, and Github style workflow when there is a fork available), and use "upstream" if there is no origin. --- build_files/utils/make_update.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build_files/utils/make_update.py b/build_files/utils/make_update.py index 982be2973b3..076a6cdf782 100755 --- a/build_files/utils/make_update.py +++ b/build_files/utils/make_update.py @@ -432,7 +432,10 @@ def external_scripts_update(args: argparse.Namespace, # Switch to branch and pull. if submodule_branch: if make_utils.git_branch(args.git_command) != submodule_branch: - call([args.git_command, "checkout", submodule_branch]) + if make_utils.git_remote_exist(args.git_command, "origin"): + call([args.git_command, "checkout", "-t", f"origin/{submodule_branch}"]) + elif make_utils.git_remote_exist(args.git_command, "upstream"): + call([args.git_command, "checkout", "-t", f"upstream/{submodule_branch}"]) # Don't use extra fetch since all remotes of interest have been already fetched # some lines above. skip_msg += work_tree_update(args, use_fetch=False) -- 2.30.2