summaryrefslogtreecommitdiffstats
path: root/subcmds
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds')
-rw-r--r--subcmds/init.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/subcmds/init.py b/subcmds/init.py
index 29730cc4..1f915268 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -19,6 +19,15 @@ import platform
19import re 19import re
20import shutil 20import shutil
21import sys 21import sys
22try:
23 # For python3
24 import urllib.parse
25except ImportError:
26 # For python2
27 import imp
28 import urlparse
29 urllib = imp.new_module('urllib')
30 urllib.parse = urlparse.urlparse
22 31
23from color import Coloring 32from color import Coloring
24from command import InteractiveCommand, MirrorSafeCommand 33from command import InteractiveCommand, MirrorSafeCommand
@@ -135,7 +144,19 @@ to update the working directory files.
135 if not opt.quiet: 144 if not opt.quiet:
136 print('Get %s' % GitConfig.ForUser().UrlInsteadOf(opt.manifest_url), 145 print('Get %s' % GitConfig.ForUser().UrlInsteadOf(opt.manifest_url),
137 file=sys.stderr) 146 file=sys.stderr)
138 m._InitGitDir() 147
148 # The manifest project object doesn't keep track of the path on the
149 # server where this git is located, so let's save that here.
150 mirrored_manifest_git = None
151 if opt.reference:
152 manifest_git_path = urllib.parse(opt.manifest_url).path[1:]
153 mirrored_manifest_git = os.path.join(opt.reference, manifest_git_path)
154 if not mirrored_manifest_git.endswith(".git"):
155 mirrored_manifest_git += ".git"
156 if not os.path.exists(mirrored_manifest_git):
157 mirrored_manifest_git = os.path.join(opt.reference + '/.repo/manifests.git')
158
159 m._InitGitDir(mirror_git=mirrored_manifest_git)
139 160
140 if opt.manifest_branch: 161 if opt.manifest_branch:
141 m.revisionExpr = opt.manifest_branch 162 m.revisionExpr = opt.manifest_branch