From 6f75785150a5bb1b861bfa825fc15c272891d733 Mon Sep 17 00:00:00 2001 From: John Schock Date: Tue, 2 Jul 2024 15:24:45 -0700 Subject: [PATCH] Add reference argument to submodule update --init invocations --- edk2toolext/environment/repo_resolver.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/edk2toolext/environment/repo_resolver.py b/edk2toolext/environment/repo_resolver.py index 78d374bf..966d2e2f 100644 --- a/edk2toolext/environment/repo_resolver.py +++ b/edk2toolext/environment/repo_resolver.py @@ -388,6 +388,9 @@ def checkout( """ details = repo_details(abs_file_system_path) with Repo(abs_file_system_path) as repo: + reference = None + if "ReferencePath" in dep and os.path.exists(dep["ReferencePath"]): + reference = Path(dep["ReferencePath"]) if "Commit" in dep: commit = dep["Commit"] if update_ok or force: @@ -397,7 +400,10 @@ def checkout( except GitCommandError: repo.git.fetch() repo.git.checkout(commit) - repo.git.submodule("update", "--init", "--recursive") + if reference: + repo.git.submodule("update", "--init", "--recursive", "--reference", reference.as_posix()) + else: + repo.git.submodule("update", "--init", "--recursive") else: head = details["Head"] if commit in [head["HexSha"], head["HexShaShort"]]: @@ -427,7 +433,10 @@ def checkout( repo.remotes.origin.config_writer.set_value("fetch", refspec).release() repo.git.fetch() repo.git.checkout(branch) - repo.git.submodule("update", "--init", "--recursive") + if reference: + repo.git.submodule("update", "--init", "--recursive", "--reference", reference.as_posix()) + else: + repo.git.submodule("update", "--init", "--recursive") else: if details["Branch"] == dep["Branch"]: logger.debug(