Extra ".git" issue when "repo init --mirror"

96 views
Skip to first unread message

Chunlin Zhang

unread,
Jul 10, 2014, 5:58:29 AM7/10/14
to repo-d...@googlegroups.com
example manifest:

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <remote fetch="https://webtech-devx.qualcomm.com/" name="swe" review="webtech-devx.qualcomm.com"/>
  <default remote="swe" revision="master"/>
  <project name="swe/packages/fast-webview.git" remote="swe" />
</manifest>

Because the git of https://webtech-devx.qualcomm.com/swe/packages/fast-webview.git should add ".git" (that is "git clone https://webtech-devx.qualcomm.com/swe/packages/fast-webview" will failed with error:"fatal: repository 'https://webtech-devx.qualcomm.com/swe/packages/fast-webview/' not found") ,so the git url should keep .git in manifest.

But when I use "repo init --mirror" with this manifest,it will get extra ".git" in path,like this:
└── swe
    └── packages
        └── fast-webview.git.git

Is this a bug?

David Pursehouse

unread,
Jul 10, 2014, 6:09:39 AM7/10/14
to Chunlin Zhang, repo-d...@googlegroups.com
Unless it causes something to fail, I think this is the expected behaviour.

When using repo in --mirror mode it clones the gits in bare mode and
appends .git onto the name. This will be the case for all the projects
in the manifest.

So if the name already ends with .git, then it will be appended again.

Note that Gerrit no longer allows projects to be created with a name
ending in ".git". IIRC this was fixed in 2.6.

Chunlin Zhang

unread,
Jul 17, 2014, 5:14:06 AM7/17/14
to David Pursehouse, repo-d...@googlegroups.com
I modify my local repo to avoid this,because I think .git.git is not reasonable.

patch:
diff --git a/manifest_xml.py b/manifest_xml.py
index dd163be..0f025a3 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -591,10 +591,18 @@ class XmlManifest(object):
 
     if self.IsMirror:
       worktree = None
-      gitdir = os.path.join(self.topdir, '%s.git' % name)
+      if name.endswith('.git'):
+        dn = name
+      else:
+        dn = '%s.git' % name
+      gitdir = os.path.join(self.topdir, dn)
     else:
       worktree = os.path.join(self.topdir, path).replace('\\', '/')
-      gitdir = os.path.join(self.repodir, 'projects/%s.git' % path)
+      if path.endswith('.git'):
+        path2 = 'projects/%s'%(path)
+      else:
+        path2 = 'projects/%s.git' % path
+      gitdir = os.path.join(self.repodir, path2)
 
     project = Project(manifest = self,
                       name = name,

David Pursehouse

unread,
Jul 17, 2014, 5:44:26 AM7/17/14
to Chunlin Zhang, repo-discuss

On 17 Jul 2014 18:14, "Chunlin Zhang" <zhangc...@gmail.com> wrote:
>
> I modify my local repo to avoid this,because I think .git.git is not reasonable.
>

But now your local mirror will have different names to the origin server.

> --
> --
> To unsubscribe, email repo-discuss...@googlegroups.com
> More info at http://groups.google.com/group/repo-discuss?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Chunlin Zhang

unread,
Jul 17, 2014, 5:56:05 AM7/17/14
to David Pursehouse, repo-discuss
On Thu, Jul 17, 2014 at 5:43 PM, David Pursehouse <david.pu...@sonymobile.com> wrote:

On 17 Jul 2014 18:14, "Chunlin Zhang" <zhangc...@gmail.com> wrote:
>
> I modify my local repo to avoid this,because I think .git.git is not reasonable.
>

But now your local mirror will have different names to the origin server.

No, it's not as your thinking.
As my example above, the whole url of git in origin server is: https://webtech-devx.qualcomm.com/swe/packages/fast-webview.git ,my local mirror is also XXX/swe/packages/fast-webview.git
Reply all
Reply to author
Forward
0 new messages