Git-subrepo: subdir with space in name fails to clone

Created on 15 Feb 2016  Â·  10Comments  Â·  Source: ingydotnet/git-subrepo

I am reconstituting a large repo from a bunch of subrepos. The original large repo has subdir with spaces in the name like 'IDE Build'. So in order to keep changes for developers to a minimum I need to use the same name. How do I do that?

git subrepo clone /c/dev/vl_ide_build 'IDE Build' -b trunk -vd
>>> git remote add subrepo/IDE Build /c/dev/vl_ide_build
git-subrepo: Command failed: 'git remote add subrepo/IDE Build /c/dev/vl_ide_build'.
Bug

Most helpful comment

I got kind of the same issue with a hidden dir (starting with a dot).

fatal: 'subrepo/.mktools' is not a valid remote name

All 10 comments

It seems that there is a bug in the escaping of spaces, so currently you can't do that :-(

This is going to be a bit tricky because git doesn't want spaces in remote or
branch names, and subrepo ties subdirs to those:

fatal: 'foo bar' is not a valid remote name
fatal: 'foo bar' is not a valid branch name.

http://stackoverflow.com/questions/6619073/why-cant-a-branch-name-contain-the-space-char

We could possibly use %20 style escaping.

I'm going to hold off for someone to have a stroke of genius here.

...drinking more coffee...

I looked into the space thing and as @ingydotnet it seems tricky.

One workaround if you really need to have certain directories named in certain ways would be to create links. Then you have the subrepo/subdir as a v1_ide_build and simply create a link "IDE Build" pointing to that one.

My bash is pretty hopeless, being a Windows programmer, but it did look
like the refs would be tricky.

​And being on Windows​, links are possible, but problematic. Though thats
how I think this should be solved. Its simple and allows effort to be spent
elsewhere.

Thanks for your help.

I got kind of the same issue with a hidden dir (starting with a dot).

fatal: 'subrepo/.mktools' is not a valid remote name

@hectorj That seems strange, I think that I have used dotted files and dirs without problem, do you have any more information?

@grimmySwe: Sure, I just reproduced it:

$ cd ~
$ git clone https://github.com/ingydotnet/git-subrepo
Cloning into 'git-subrepo'...
remote: Counting objects: 2595, done.
remote: Total 2595 (delta 0), reused 0 (delta 0), pack-reused 2595
Receiving objects: 100% (2595/2595), 724.34 KiB | 233.00 KiB/s, done.
Resolving deltas: 100% (1331/1331), done.
Checking connectivity... done.
$ echo 'source ~/git-subrepo/.rc' >> ~/.bashrc
$ source ~/git-subrepo/.rc
$ mkdir subrepotest
$ cd subrepotest/
$ git init
Initialized empty Git repository in /home/hectorj/subrepotest/.git/
$ git-subrepo clone https://github.com/hectorj/go-tools-makefile.git .mktools
git-subrepo: Command failed: 'git remote add subrepo/.mktools https://github.com/hectorj/go-tools-makefile.git'.
$ git remote add subrepo/.mktools https://github.com/hectorj/go-tools-makefile.git
fatal: 'subrepo/.mktools' is not a valid remote name
$ git --version
git version 1.9.1
$ git-subrepo --version
0.3.0

Getting the exact same issue when trying to clone to a directory that starts with a dot:

$ ls -lha
total 8,0K
drwxrwxr-x 2 rick rick 4,0K mei 27 15:54 .
drwx------ 58 rick rick 4,0K mei 27 15:54 ..

$ git-subrepo --version
0.3.0

This breaks

$ git init
Initialized empty Git repository in /home/rick/test/.git/
rick@lt-rick:~/test (master #)$ git subrepo clone [email protected]:muntzamersfoort/muntz-logictrade.git .modman/muntz-logictrade
git-subrepo: Command failed: 'git remote add subrepo/.modman/muntz-logictrade [email protected]:muntzamersfoort/muntz-logictrade.git'.

Works fine without the dot

$ git subrepo clone [email protected]:muntzamersfoort/muntz-logictrade.git modman/muntz-logictrade
Subrepo '[email protected]:muntzamersfoort/muntz-logictrade.git' (master) cloned into 'modman/muntz-logictrade'.

git-subrepo tries to create git remotes with the folder name as remote name. Due to the remote / branch naming limitation, described here: https://stackoverflow.com/questions/3651860/which-characters-are-illegal-within-a-branch-name, git itself fails.

git subrepo clone https://github.com/ingydotnet/git-subrepo.git .test
...
++ git remote add subrepo/.test https://github.com/ingydotnet/git-subrepo.git

  • out='fatal: '''subrepo/.test''' is not a valid remote name'

this pr #231 try to fix this problem by encoding the invalid parts to a safe git ref.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

varac picture varac  Â·  4Comments

nandbert picture nandbert  Â·  4Comments

csteinlehner picture csteinlehner  Â·  12Comments

Wagner59 picture Wagner59  Â·  8Comments

psorowka picture psorowka  Â·  5Comments