From 68d69635c7bfef6ed8a5c7e29246265611471e0f Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Tue, 7 Jun 2022 18:24:20 +0000 Subject: [PATCH] Fix Projects.shareable_dirs If this tree is not using alternates for object sharing, then we need to continue to call it a shared directory. Bug: https://bugs.chromium.org/p/gerrit/issues/detail?id=15982 Test: manual Change-Id: I1750f10b192504ac67f552222f8ddb9809d344fe Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/338974 Tested-by: LaMont Jones Reviewed-by: Mike Frysinger --- project.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/project.py b/project.py index 8fed8f5e..48cf08c6 100644 --- a/project.py +++ b/project.py @@ -464,7 +464,13 @@ class RemoteSpec(object): class Project(object): # These objects can be shared between several working trees. - shareable_dirs = ['hooks', 'rr-cache'] + @property + def shareable_dirs(self): + """Return the shareable directories""" + if self.UseAlternates: + return ['hooks', 'rr-cache'] + else: + return ['hooks', 'objects', 'rr-cache'] def __init__(self, manifest, @@ -594,6 +600,14 @@ class Project(object): self.bare_ref = GitRefs(self.gitdir) self.bare_objdir = self._GitGetByExec(self, bare=True, gitdir=self.objdir) + @property + def UseAlternates(self): + """Whether git alternates are in use. + + This will be removed once migration to alternates is complete. + """ + return _ALTERNATES or self.manifest.is_multimanifest + @property def Derived(self): return self.is_derived @@ -1147,7 +1161,7 @@ class Project(object): self._UpdateHooks(quiet=quiet) self._InitRemote() - if _ALTERNATES or self.manifest.is_multimanifest: + if self.UseAlternates: # If gitdir/objects is a symlink, migrate it from the old layout. gitdir_objects = os.path.join(self.gitdir, 'objects') if platform_utils.islink(gitdir_objects):