Prechádzať zdrojové kódy

Merge changes I9c1ab65f,I7b2027ae

* changes:
  init: Remove string concat in no-op os.path.join
  Support relative paths in --reference
David Pursehouse 8 rokov pred
rodič
commit
4ea1f0cabd
2 zmenil súbory, kde vykonal 9 pridanie a 3 odobranie
  1. 6 1
      project.py
  2. 3 2
      subcmds/init.py

+ 6 - 1
project.py

@@ -1270,7 +1270,8 @@ class Project(object):
       try:
         fd = open(alt)
         try:
-          alt_dir = fd.readline().rstrip()
+          # This works for both absolute and relative alternate directories.
+          alt_dir = os.path.join(self.objdir, 'objects', fd.readline().rstrip())
         finally:
           fd.close()
       except IOError:
@@ -2361,6 +2362,10 @@ class Project(object):
             ref_dir = None
 
           if ref_dir:
+            if not os.path.isabs(ref_dir):
+              # The alternate directory is relative to the object database.
+              ref_dir = os.path.relpath(ref_dir,
+                                        os.path.join(self.objdir, 'objects'))
             _lwrite(os.path.join(self.gitdir, 'objects/info/alternates'),
                     os.path.join(ref_dir, 'objects') + '\n')
 

+ 3 - 2
subcmds/init.py

@@ -175,7 +175,8 @@ to update the working directory files.
         if not mirrored_manifest_git.endswith(".git"):
           mirrored_manifest_git += ".git"
         if not os.path.exists(mirrored_manifest_git):
-          mirrored_manifest_git = os.path.join(opt.reference + '/.repo/manifests.git')
+          mirrored_manifest_git = os.path.join(opt.reference,
+                                               '.repo/manifests.git')
 
       m._InitGitDir(mirror_git=mirrored_manifest_git)
 
@@ -401,7 +402,7 @@ to update the working directory files.
     git_require(MIN_GIT_VERSION, fail=True)
 
     if opt.reference:
-      opt.reference = os.path.abspath(os.path.expanduser(opt.reference))
+      opt.reference = os.path.expanduser(opt.reference)
 
     # Check this here, else manifest will be tagged "not new" and init won't be
     # possible anymore without removing the .repo/manifests directory.