diff options
author | David Pursehouse <dpursehouse@collab.net> | 2018-03-16 02:06:10 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-03-16 02:06:10 +0000 |
commit | 4ea1f0cabdda28fdee837ee2f99e14375028b5f4 (patch) | |
tree | 0f3c43a263dbc368a91577442a91ed2de0f0629c | |
parent | 7d52585ec4719ce0314c6d1a20216fc0128d6883 (diff) | |
parent | 5f0e57d2ca28dad4e0f32849609c1857abb596fc (diff) | |
download | git-repo-4ea1f0cabdda28fdee837ee2f99e14375028b5f4.tar.gz |
Merge changes I9c1ab65f,I7b2027ae
* changes:
init: Remove string concat in no-op os.path.join
Support relative paths in --reference
-rw-r--r-- | project.py | 7 | ||||
-rw-r--r-- | subcmds/init.py | 5 |
2 files changed, 9 insertions, 3 deletions
@@ -1270,7 +1270,8 @@ class Project(object): | |||
1270 | try: | 1270 | try: |
1271 | fd = open(alt) | 1271 | fd = open(alt) |
1272 | try: | 1272 | try: |
1273 | alt_dir = fd.readline().rstrip() | 1273 | # This works for both absolute and relative alternate directories. |
1274 | alt_dir = os.path.join(self.objdir, 'objects', fd.readline().rstrip()) | ||
1274 | finally: | 1275 | finally: |
1275 | fd.close() | 1276 | fd.close() |
1276 | except IOError: | 1277 | except IOError: |
@@ -2361,6 +2362,10 @@ class Project(object): | |||
2361 | ref_dir = None | 2362 | ref_dir = None |
2362 | 2363 | ||
2363 | if ref_dir: | 2364 | if ref_dir: |
2365 | if not os.path.isabs(ref_dir): | ||
2366 | # The alternate directory is relative to the object database. | ||
2367 | ref_dir = os.path.relpath(ref_dir, | ||
2368 | os.path.join(self.objdir, 'objects')) | ||
2364 | _lwrite(os.path.join(self.gitdir, 'objects/info/alternates'), | 2369 | _lwrite(os.path.join(self.gitdir, 'objects/info/alternates'), |
2365 | os.path.join(ref_dir, 'objects') + '\n') | 2370 | os.path.join(ref_dir, 'objects') + '\n') |
2366 | 2371 | ||
diff --git a/subcmds/init.py b/subcmds/init.py index eeddca06..47a1c9fa 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
@@ -175,7 +175,8 @@ to update the working directory files. | |||
175 | if not mirrored_manifest_git.endswith(".git"): | 175 | if not mirrored_manifest_git.endswith(".git"): |
176 | mirrored_manifest_git += ".git" | 176 | mirrored_manifest_git += ".git" |
177 | if not os.path.exists(mirrored_manifest_git): | 177 | if not os.path.exists(mirrored_manifest_git): |
178 | mirrored_manifest_git = os.path.join(opt.reference + '/.repo/manifests.git') | 178 | mirrored_manifest_git = os.path.join(opt.reference, |
179 | '.repo/manifests.git') | ||
179 | 180 | ||
180 | m._InitGitDir(mirror_git=mirrored_manifest_git) | 181 | m._InitGitDir(mirror_git=mirrored_manifest_git) |
181 | 182 | ||
@@ -401,7 +402,7 @@ to update the working directory files. | |||
401 | git_require(MIN_GIT_VERSION, fail=True) | 402 | git_require(MIN_GIT_VERSION, fail=True) |
402 | 403 | ||
403 | if opt.reference: | 404 | if opt.reference: |
404 | opt.reference = os.path.abspath(os.path.expanduser(opt.reference)) | 405 | opt.reference = os.path.expanduser(opt.reference) |
405 | 406 | ||
406 | # Check this here, else manifest will be tagged "not new" and init won't be | 407 | # Check this here, else manifest will be tagged "not new" and init won't be |
407 | # possible anymore without removing the .repo/manifests directory. | 408 | # possible anymore without removing the .repo/manifests directory. |