diff options
author | Samuel Holland <samuel@sholland.org> | 2018-01-22 10:57:29 -0600 |
---|---|---|
committer | Samuel Holland <samuel@sholland.org> | 2018-01-22 10:57:29 -0600 |
commit | baa00093557d4e7e41d67ac8acfd4daccb154afd (patch) | |
tree | 0e33063af6c7b3d900ba3313efa3bfffb9dc505a /project.py | |
parent | 685320b000c0683421a460d1c9a33ae9d73cc706 (diff) | |
download | git-repo-baa00093557d4e7e41d67ac8acfd4daccb154afd.tar.gz |
Support relative paths in --reference
Put the correctly-expanded relative paths in objects/info/alternates.
From gitrepository-layout(5), this path should be "relative to the
object database, not to the repository".
Change-Id: I7b2027ae23cf7d367b80f5a187603c4cbacdb2de
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -1267,7 +1267,8 @@ class Project(object): | |||
1267 | try: | 1267 | try: |
1268 | fd = open(alt) | 1268 | fd = open(alt) |
1269 | try: | 1269 | try: |
1270 | alt_dir = fd.readline().rstrip() | 1270 | # This works for both absolute and relative alternate directories. |
1271 | alt_dir = os.path.join(self.objdir, 'objects', fd.readline().rstrip()) | ||
1271 | finally: | 1272 | finally: |
1272 | fd.close() | 1273 | fd.close() |
1273 | except IOError: | 1274 | except IOError: |
@@ -2353,6 +2354,10 @@ class Project(object): | |||
2353 | ref_dir = None | 2354 | ref_dir = None |
2354 | 2355 | ||
2355 | if ref_dir: | 2356 | if ref_dir: |
2357 | if not os.path.isabs(ref_dir): | ||
2358 | # The alternate directory is relative to the object database. | ||
2359 | ref_dir = os.path.relpath(ref_dir, | ||
2360 | os.path.join(self.objdir, 'objects')) | ||
2356 | _lwrite(os.path.join(self.gitdir, 'objects/info/alternates'), | 2361 | _lwrite(os.path.join(self.gitdir, 'objects/info/alternates'), |
2357 | os.path.join(ref_dir, 'objects') + '\n') | 2362 | os.path.join(ref_dir, 'objects') + '\n') |
2358 | 2363 | ||