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 <lamontjones@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
diff --git a/project.py b/project.py
index 8fed8f5..48cf08c 100644
--- a/project.py
+++ b/project.py
@@ -464,7 +464,13 @@
 
 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,
@@ -595,6 +601,14 @@
     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 @@
       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):