mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-01-02 16:14:25 +00:00
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
This commit is contained in:
parent
685320b000
commit
baa0009355
@ -1267,7 +1267,8 @@ class Project(object):
|
|||||||
try:
|
try:
|
||||||
fd = open(alt)
|
fd = open(alt)
|
||||||
try:
|
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:
|
finally:
|
||||||
fd.close()
|
fd.close()
|
||||||
except IOError:
|
except IOError:
|
||||||
@ -2353,6 +2354,10 @@ class Project(object):
|
|||||||
ref_dir = None
|
ref_dir = None
|
||||||
|
|
||||||
if ref_dir:
|
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'),
|
_lwrite(os.path.join(self.gitdir, 'objects/info/alternates'),
|
||||||
os.path.join(ref_dir, 'objects') + '\n')
|
os.path.join(ref_dir, 'objects') + '\n')
|
||||||
|
|
||||||
|
@ -401,7 +401,7 @@ to update the working directory files.
|
|||||||
git_require(MIN_GIT_VERSION, fail=True)
|
git_require(MIN_GIT_VERSION, fail=True)
|
||||||
|
|
||||||
if opt.reference:
|
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
|
# Check this here, else manifest will be tagged "not new" and init won't be
|
||||||
# possible anymore without removing the .repo/manifests directory.
|
# possible anymore without removing the .repo/manifests directory.
|
||||||
|
Loading…
Reference in New Issue
Block a user