Reputation: 313
I tried using the answer involving git-filterbranch from this question Combining multiple git repositories but running in trouble because this answer doesn't seems to work when repository name has 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, which is failing:
/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, which 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 can I tweak this git filter-branch call to support repository names having a space in them?
Upvotes: 0
Views: 1216
Reputation: 313
I finally asked the question on the git mailing list: one of the member came with an answer : some quotes should be added to the mv sub-command, they have updated the documentation : see last sample from http://git-scm.com/docs/git-filter-branch
Upvotes: 1
Reputation: 497202
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.
Upvotes: 0