Search code examples
windowsgitrepo

Google repo tool (master branch) fails to sync from local mirror on Windows


Recently master branch for Google repo tool has been updated to support Windows OS. It is clear from commit logs : https://gerrit.googlesource.com/git-repo/+log

I am able to run basic commands like repo init and repo sync using repo tool on Windows (which makes use of MinGW Git on Windows). In my work I need to create a local mirror of a repository and then use it. repo tool works fine to create mirror repository.

Here are commands used to create mirror repository on local drive on Windows OS.

$ repo.cmd init -u <URL> -b <branch_name> -m <manifest_file_name> --mirror --no-repo-verify

$ repo.cmd sync --no-tags
  • --no-repo-verify is used to forcefully use master branch of repo tool.
  • The above commands create the mirror in local drive C:\git-repo\test\mirror-testing\mirror

But when I refer the above mirror to sync in other drive then it shows error.

Command:
$ repo.cmd init -u <URL> -b <Branch_name> -m <manifest_file_name> --reference="C:\git-repo\test\mirror-testing\mirror" --no-repo-verify

Error:
error: object directory C:/git-repo/test/mirror-testing/mirror/project/manifest.git/objects? does not exist; check .git/objects/info/alternates.

The above command creates alternates file in C:/git-repo/test/mirror-testing/mirror/project/manifest.git/objects/info/ directory and that file contains below path:

C:\git-repo\test\mirror-testing\mirror\project/manifest.git\objects

I have tried other formats to provide reference value:

Git format: "/C/git-repo/test/mirror-testing/mirror"
Cygwin format: "/cygdrive/c/git-repo/test/mirror-testing/mirror"

Using above formats in reference does not create alternates file in objects directory.

repo init time in all above cases simply suggests that mirror is not referred and init is done from network.

When I repeat the same test with Cygwin Git + Google repo tool (stable branch) then I do not see any error and repo init time and sync time is very less compared to the mirror init and sync time, which simply suggests that mirror is referred.

  • repo.cmd is a batch file wrapper to invoke repo tool with python. repo.cmd file contains single line

    @call python %~dp0\repo %*

  • I am using Cygwin terminal in Windows 7 to run these commands.

  • To be clear repo init and repo sync shows error while referring to mirror but it completes successfully by syncing from outside network. The issue is that mirror is not referred.

Has anyone used Google repo on Windows for creating mirror and syncing in other drive using as reference?


Solution

  • I have tested Google repo tool master branch with MinGW Git on Windows 7 and Windows 10. repo init and repo sync work on both OS.

    Even creating the local mirror using --mirror is working, but referring that local mirror to sync in other drive does not work and displays error: "object directory not found".

    To be clear using --reference with local mirror shows error, but it eventually uses the network and ignores the local mirror. Ultimately the command completes successfully, but it does not make the use of local mirror. I do not see any workaround for this on Windows for now.

    Meanwhile Windows 10 supports Linux bash natively without using any VM. WSL, the Windows Subsystem for Linux, is a free, optional feature of Windows 10 that allows Linux programs to run on Windows. It provides you with a Windows version of the bash shell and a compatibility layer that permits many Linux programs to run natively on your Windows machine. Using this option you can replace Cygwin Git with Linux Git.

    I have tested repo tool on Linux Bash (with Ubuntu distribution installed) for repo init, sync, mirror and reference commands and it works. In fact we use Linux bash so simply Goole repo stable branch works, you do not need to use the master branch to make it work.