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 | |
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
-rw-r--r-- | project.py | 7 | ||||
-rw-r--r-- | subcmds/init.py | 2 |
2 files changed, 7 insertions, 2 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 | ||
diff --git a/subcmds/init.py b/subcmds/init.py index eeddca06..9466b9a2 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
@@ -401,7 +401,7 @@ to update the working directory files. | |||
401 | git_require(MIN_GIT_VERSION, fail=True) | 401 | git_require(MIN_GIT_VERSION, fail=True) |
402 | 402 | ||
403 | if opt.reference: | 403 | if opt.reference: |
404 | opt.reference = os.path.abspath(os.path.expanduser(opt.reference)) | 404 | opt.reference = os.path.expanduser(opt.reference) |
405 | 405 | ||
406 | # Check this here, else manifest will be tagged "not new" and init won't be | 406 | # Check this here, else manifest will be tagged "not new" and init won't be |
407 | # possible anymore without removing the .repo/manifests directory. | 407 | # possible anymore without removing the .repo/manifests directory. |