diff options
author | Mike Frysinger <vapier@google.com> | 2021-12-20 21:17:43 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2022-01-13 18:27:28 +0000 |
commit | 152032cca2a77f36e5a0c6943b66fd630c79b0e7 (patch) | |
tree | 6c61d1177c11ff3697e288a5cb68060892158c44 /project.py | |
parent | a3ac81627885f78b9391ff291c4a5bc617494045 (diff) | |
download | git-repo-152032cca2a77f36e5a0c6943b66fd630c79b0e7.tar.gz |
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>
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -1120,7 +1120,7 @@ class Project(object): | |||
1120 | self._InitRemote() | 1120 | self._InitRemote() |
1121 | 1121 | ||
1122 | if is_new: | 1122 | if is_new: |
1123 | alt = os.path.join(self.gitdir, 'objects/info/alternates') | 1123 | alt = os.path.join(self.objdir, 'objects/info/alternates') |
1124 | try: | 1124 | try: |
1125 | with open(alt) as fd: | 1125 | with open(alt) as fd: |
1126 | # This works for both absolute and relative alternate directories. | 1126 | # This works for both absolute and relative alternate directories. |
@@ -1169,7 +1169,7 @@ class Project(object): | |||
1169 | mp = self.manifest.manifestProject | 1169 | mp = self.manifest.manifestProject |
1170 | dissociate = mp.config.GetBoolean('repo.dissociate') | 1170 | dissociate = mp.config.GetBoolean('repo.dissociate') |
1171 | if dissociate: | 1171 | if dissociate: |
1172 | alternates_file = os.path.join(self.gitdir, 'objects/info/alternates') | 1172 | alternates_file = os.path.join(self.objdir, 'objects/info/alternates') |
1173 | if os.path.exists(alternates_file): | 1173 | if os.path.exists(alternates_file): |
1174 | cmd = ['repack', '-a', '-d'] | 1174 | cmd = ['repack', '-a', '-d'] |
1175 | p = GitCommand(self, cmd, bare=True, capture_stdout=bool(output_redir), | 1175 | p = GitCommand(self, cmd, bare=True, capture_stdout=bool(output_redir), |
@@ -2504,8 +2504,8 @@ class Project(object): | |||
2504 | if ref_dir or mirror_git: | 2504 | if ref_dir or mirror_git: |
2505 | if not mirror_git: | 2505 | if not mirror_git: |
2506 | mirror_git = os.path.join(ref_dir, self.name + '.git') | 2506 | mirror_git = os.path.join(ref_dir, self.name + '.git') |
2507 | repo_git = os.path.join(ref_dir, '.repo', 'projects', | 2507 | repo_git = os.path.join(ref_dir, '.repo', 'project-objects', |
2508 | self.relpath + '.git') | 2508 | self.name + '.git') |
2509 | worktrees_git = os.path.join(ref_dir, '.repo', 'worktrees', | 2509 | worktrees_git = os.path.join(ref_dir, '.repo', 'worktrees', |
2510 | self.name + '.git') | 2510 | self.name + '.git') |
2511 | 2511 | ||
@@ -2523,7 +2523,7 @@ class Project(object): | |||
2523 | # The alternate directory is relative to the object database. | 2523 | # The alternate directory is relative to the object database. |
2524 | ref_dir = os.path.relpath(ref_dir, | 2524 | ref_dir = os.path.relpath(ref_dir, |
2525 | os.path.join(self.objdir, 'objects')) | 2525 | os.path.join(self.objdir, 'objects')) |
2526 | _lwrite(os.path.join(self.gitdir, 'objects/info/alternates'), | 2526 | _lwrite(os.path.join(self.objdir, 'objects/info/alternates'), |
2527 | os.path.join(ref_dir, 'objects') + '\n') | 2527 | os.path.join(ref_dir, 'objects') + '\n') |
2528 | 2528 | ||
2529 | m = self.manifest.manifestProject.config | 2529 | m = self.manifest.manifestProject.config |