Skip to content

Commit 61c1e1a

Browse files
auto-cache: avoid using HEAD after cloning from a cache
This commit removes existing code, which uses HEAD right after cloning the repository into the workspace from a cache. Background: When a remote default branch is renamed and the auto-cache is updated with remote, the auto-cache becomes corrupt as HEAD points to an invalid remote HEAD. Therefore, avoid using HEAD within git operations during west update, as long as no revision is checked out.
1 parent b783b74 commit 61c1e1a

File tree

1 file changed

+0
-23
lines changed

1 file changed

+0
-23
lines changed

src/west/app/project.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,29 +1821,6 @@ def init_project(self, project):
18211821
)
18221822
# Reset the remote's URL to the project's fetch URL.
18231823
project.git(['remote', 'set-url', project.remote_name, project.url])
1824-
# Make sure we have a detached HEAD so we can delete the
1825-
# local branch created by git clone.
1826-
project.git('checkout --quiet --detach HEAD')
1827-
# Find the name of any local branch created by git clone.
1828-
# West commits to only touching 'manifest-rev' in the
1829-
# local branch name space.
1830-
local_branches = (
1831-
project.git(
1832-
['for-each-ref', '--format', '%(refname)', 'refs/heads/*'], capture_stdout=True
1833-
)
1834-
.stdout.decode('utf-8')
1835-
.splitlines()
1836-
)
1837-
# This should contain at most one branch in current
1838-
# versions of git, but we might as well get them all just
1839-
# in case that changes.
1840-
for branch in local_branches:
1841-
if not branch:
1842-
continue
1843-
# This is safe: it can't be garbage collected by git before we
1844-
# have a chance to use it, because we have another ref, namely
1845-
# f'refs/remotes/{project.remote_name}/{branch}'.
1846-
project.git(['update-ref', '-d', branch])
18471824

18481825
def project_auto_cache(self, project):
18491826
if self.auto_cache is None:

0 commit comments

Comments
 (0)