tags:

views:

31

answers:

1

I tried using the answer involing git-filterbranch from this question http://stackoverflow.com/questions/277029/combining-multiple-git-repositories but running in trouble because this answer doesn't seems to work when repository name having a space in its name.

For example, this wouldn't work if the repository would be called "my figures" instead of "figures".

I'm running msysgit.

Here is a sample, with a "my figures" repository, wich is failling :

/d/git/my figures (master)
$ git filter-branch --index-filter \
> 'git ls-files -s | sed "s-\t-&my figures/-" |
> GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
> git update-index --index-info &&
> mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD
Rewrite d9f3a10522f2a0e1531f45e8e7b3a518f0d714c5 (1/1)mv: when moving multiple files, last argument must be a directory
Try `mv --help' for more information.
index filter failed: git ls-files -s | sed "s-\t-&my figures/-" |
GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
git update-index --index-info &&
mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE
rm: cannot remove `d:/git/my figures/.git-rewrite/revs': Permission denied
rm: cannot remove directory `d:/git/my figures/.git-rewrite': Directory not empty

The, retrying with the repository renamed a myfigures, wich is working fine :

/d/git/myfigures (master)
$ git filter-branch --index-filter 'git ls-files -s | sed "s-\t-&myfigures/-" |
GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
git update-index --index-info &&
mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD
Rewrite d9f3a10522f2a0e1531f45e8e7b3a518f0d714c5 (1/1)
Ref 'refs/heads/master' was rewritten

So, how tweaking this git filter-branch call to support repository name having a space in them ?

A: 

I believe it should be sufficient to quote the filenames you're passing into git update-index:

... | sed "s-\t-&\"my figures\"-" | ...

Of course, the quoting/escaping would be a little simpler if you put the filter into its own file - this wouldn't all be surrounded by single quotes.

Jefromi
The sed expression you suggested doesn't work.
jfburdet
@jfburdet: Doesn't work how, exactly? And is the msysgit shell like sh/bash in terms of quoting?
Jefromi
jfburdet
@Jefromi : In fact, the shell IS bash, but running under windows. I don't think It would be different under a real unix OS.
jfburdet
Tried using an ubuntu vm, got exactly same problem.
jfburdet