From 152032cca2a77f36e5a0c6943b66fd630c79b0e7 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 20 Dec 2021 21:17:43 -0500 Subject: [PATCH] project: move --reference handling to project-objects When using --reference, the path is written to objects/info/alternates. The path is accessed inconsistently -- sometimes through projects/ (via self.gitdir) and sometimes through project-objects/ (via self.objdir). This works because projects/.../objects is a symlink to the objects dir under project-objects/. Change all accesses to go through self.objdir. This will allow us to stop symlinking projects/.../objects without the reference dir logic breaking. The projects/ path is going to use its alternates file for its own needs. Bug: https://crbug.com/gerrit/15553 Change-Id: I6b452ad1aaffec74ecb7ac1bb9baa3a3a52e076c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/328099 Tested-by: Mike Frysinger Reviewed-by: Jack Neus --- project.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/project.py b/project.py index 338feffa..8598de36 100644 --- a/project.py +++ b/project.py @@ -1120,7 +1120,7 @@ class Project(object): self._InitRemote() if is_new: - alt = os.path.join(self.gitdir, 'objects/info/alternates') + alt = os.path.join(self.objdir, 'objects/info/alternates') try: with open(alt) as fd: # This works for both absolute and relative alternate directories. @@ -1169,7 +1169,7 @@ class Project(object): mp = self.manifest.manifestProject dissociate = mp.config.GetBoolean('repo.dissociate') if dissociate: - alternates_file = os.path.join(self.gitdir, 'objects/info/alternates') + alternates_file = os.path.join(self.objdir, 'objects/info/alternates') if os.path.exists(alternates_file): cmd = ['repack', '-a', '-d'] p = GitCommand(self, cmd, bare=True, capture_stdout=bool(output_redir), @@ -2504,8 +2504,8 @@ class Project(object): if ref_dir or mirror_git: if not mirror_git: mirror_git = os.path.join(ref_dir, self.name + '.git') - repo_git = os.path.join(ref_dir, '.repo', 'projects', - self.relpath + '.git') + repo_git = os.path.join(ref_dir, '.repo', 'project-objects', + self.name + '.git') worktrees_git = os.path.join(ref_dir, '.repo', 'worktrees', self.name + '.git') @@ -2523,7 +2523,7 @@ class Project(object): # The alternate directory is relative to the object database. ref_dir = os.path.relpath(ref_dir, os.path.join(self.objdir, 'objects')) - _lwrite(os.path.join(self.gitdir, 'objects/info/alternates'), + _lwrite(os.path.join(self.objdir, 'objects/info/alternates'), os.path.join(ref_dir, 'objects') + '\n') m = self.manifest.manifestProject.config