martinjina / git-repo

Automatically exported from code.google.com/p/git-repo
Apache License 2.0
0 stars 0 forks source link

repo init failed when switching from a manifest to another inside a mirror #200

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I have a mirror created with:

 - repo init --mirror -b master -m base.xml && repo sync

I'm using the same directory to track different "flavors" of the sources, each 
"flavor" having its own manifest in .repo/manifests (and tracked inside the 
same git repository).

In order to update the mirror for the various "flavors", I switch from a 
manifest to another and sync:

 - repo init -m base.xml && repo sync
 - repo init -m flavor0.xml && repo sync
 - repo init -m flavor1.xml && repo sync

But since v1.12.24 and commit 384b3c594831 ('Fail if gitdir does not point to 
objdir during sync') [1], repo init -m <manifest>.xml fail with following error 
message:

Traceback (most recent call last):
  File "/home/ydroneaud/src/mirror/.repo/repo/main.py", line 506, in <module>
    _Main(sys.argv[1:])
  File "/home/ydroneaud/src/mirror/.repo/repo/main.py", line 482, in _Main
    result = repo._Run(argv) or 0
  File "/home/ydroneaud/src/mirror/.repo/repo/main.py", line 161, in _Run
    result = cmd.Execute(copts, cargs)
  File "/home/ydroneaud/src/mirror/.repo/repo/subcmds/init.py", line 390, in Execute
    self._SyncManifest(opt)
  File "/home/ydroneaud/src/mirror/.repo/repo/subcmds/init.py", line 236, in _SyncManifest
    m.MetaBranchSwitch()
  File "/home/ydroneaud/src/mirror/.repo/repo/project.py", line 2732, in MetaBranchSwitch
    self.Sync_LocalHalf(syncbuf)
  File "/home/ydroneaud/src/mirror/.repo/repo/project.py", line 1201, in Sync_LocalHalf
    self._InitWorkTree()
  File "/home/ydroneaud/src/mirror/.repo/repo/project.py", line 2319, in _InitWorkTree
    self._CheckDirReference(self.gitdir, dotgit, share_refs=True)
  File "/home/ydroneaud/src/mirror/.repo/repo/project.py", line 2254, in _CheckDirReference
    raise GitError('cannot overwrite a local work tree')
error.GitError: cannot overwrite a local work tree

I understand the issue the commit is trying to catch, but it doesn't make 
anything to avoid the issue, it doesn't do anything to recover from the issue 
and doesn't give a hint to fix the issue.

I've modified project.py to return some information to try to understand the 
issue I'm experiencing with v1.12.24:

diff --git a/project.py b/project.py
index 00f6b90457a1..d5516ce90ca4 100644
--- a/project.py
+++ b/project.py
@@ -2301,6 +2301,7 @@ class Project(object):
         src = os.path.realpath(os.path.join(srcdir, name))
         # Fail if the links are pointing to the wrong place
         if src != dst:
+          print(' srcdir = %s\n destdir = %s\n name = %s\n src = %s\n dst = 
%s\n' % (srcdir, destdir, name, src, dst))
           raise GitError('cannot overwrite a local work tree')

   def _ReferenceGitDir(self, gitdir, dotgit, share_refs, copy_all):

Then I'm getting the following information when repo init failed:

 srcdir = /home/ydroneaud/src/sdk2/mirrors/allinone/.repo/manifests.git
 destdir = /home/ydroneaud/src/sdk2/mirrors/allinone/.repo/manifests/.git
 name = config
 src = /home/ydroneaud/src/sdk2/mirrors/allinone/.repo/manifests.git/config
 dst = /home/ydroneaud/src/sdk2/mirrors/allinone/.repo/manifests/.git/config

I don't see any problem here: files in manifests/.git/ are expected to be 
symlinks to manifests.git/ files.

It sounds like a regression. So I'm stuck with v1.12.23 which allows me to 
switch from manifest and update my mirror.

[1] 
https://gerrit.googlesource.com/git-repo/+/384b3c594831e79348a2eb98809ef9f3e34f6
aa2

Regards.

Original issue reported on code.google.com by yann@droneaud.fr on 27 Jul 2015 at 11:33

GoogleCodeExporter commented 8 years ago
Oh, it seems .repo/manifests/.git/config in the mirror directory is no more a 
symlink.

Perhaps I have hand-edited it.

(Until today, I thought .git/config, like .git/HEAD, would have been local to 
the working tree).

On a new, freshly initialized and sync'ed work tree, all .git/config are 
symlinks.

But on my daily work tree, half of the projects have a non-symlink .git/config 
and another half have a symlink .git/config. I'm puzzled, as I don't know why 
they're so many of non-symlink: I'm sure I haven't hand-modified all of them.

Original comment by yann@droneaud.fr on 27 Jul 2015 at 12:37