mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
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 <vapier@google.com> Reviewed-by: Jack Neus <jackneus@google.com>
This commit is contained in:
parent
a3ac816278
commit
152032cca2
10
project.py
10
project.py
@ -1120,7 +1120,7 @@ class Project(object):
|
|||||||
self._InitRemote()
|
self._InitRemote()
|
||||||
|
|
||||||
if is_new:
|
if is_new:
|
||||||
alt = os.path.join(self.gitdir, 'objects/info/alternates')
|
alt = os.path.join(self.objdir, 'objects/info/alternates')
|
||||||
try:
|
try:
|
||||||
with open(alt) as fd:
|
with open(alt) as fd:
|
||||||
# This works for both absolute and relative alternate directories.
|
# This works for both absolute and relative alternate directories.
|
||||||
@ -1169,7 +1169,7 @@ class Project(object):
|
|||||||
mp = self.manifest.manifestProject
|
mp = self.manifest.manifestProject
|
||||||
dissociate = mp.config.GetBoolean('repo.dissociate')
|
dissociate = mp.config.GetBoolean('repo.dissociate')
|
||||||
if 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):
|
if os.path.exists(alternates_file):
|
||||||
cmd = ['repack', '-a', '-d']
|
cmd = ['repack', '-a', '-d']
|
||||||
p = GitCommand(self, cmd, bare=True, capture_stdout=bool(output_redir),
|
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 ref_dir or mirror_git:
|
||||||
if not mirror_git:
|
if not mirror_git:
|
||||||
mirror_git = os.path.join(ref_dir, self.name + '.git')
|
mirror_git = os.path.join(ref_dir, self.name + '.git')
|
||||||
repo_git = os.path.join(ref_dir, '.repo', 'projects',
|
repo_git = os.path.join(ref_dir, '.repo', 'project-objects',
|
||||||
self.relpath + '.git')
|
self.name + '.git')
|
||||||
worktrees_git = os.path.join(ref_dir, '.repo', 'worktrees',
|
worktrees_git = os.path.join(ref_dir, '.repo', 'worktrees',
|
||||||
self.name + '.git')
|
self.name + '.git')
|
||||||
|
|
||||||
@ -2523,7 +2523,7 @@ class Project(object):
|
|||||||
# The alternate directory is relative to the object database.
|
# The alternate directory is relative to the object database.
|
||||||
ref_dir = os.path.relpath(ref_dir,
|
ref_dir = os.path.relpath(ref_dir,
|
||||||
os.path.join(self.objdir, 'objects'))
|
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')
|
os.path.join(ref_dir, 'objects') + '\n')
|
||||||
|
|
||||||
m = self.manifest.manifestProject.config
|
m = self.manifest.manifestProject.config
|
||||||
|
Loading…
Reference in New Issue
Block a user