From 13225b70bc0da1fbbd198531992db97dfa1eb19a Mon Sep 17 00:00:00 2001 From: Josip Sokcevic Date: Thu, 14 Oct 2021 22:24:00 +0000 Subject: [PATCH] Force set HEAD to refs/heads/main for git_cache We only build git_cache if main branch exists, and newly boostrap caches have main as default. This sets HEAD for already boostrapped caches, in case they were boostrapped before the default branch change. R=gavinmak@google.com Bug: 1251783 Change-Id: I715329ee06cf523f9fe2e6a324381dc5703bac34 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3218281 Auto-Submit: Josip Sokcevic Commit-Queue: Gavin Mak Reviewed-by: Gavin Mak --- git_cache.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/git_cache.py b/git_cache.py index a76816da6..82a3108b8 100755 --- a/git_cache.py +++ b/git_cache.py @@ -390,6 +390,10 @@ class Mirror(object): if depth and os.path.exists(os.path.join(self.mirror_path, 'shallow')): logging.warning( 'Shallow fetch requested, but repo cache already exists.') + # Old boostraps may have old default HEAD, so this ensures main is always + # used. + self.RunGit(['symbolic-ref', 'HEAD', 'refs/heads/main'], + cwd=self.mirror_path) return if not self.exists():