0

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?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
jfburdet
  • 313
  • 3
  • 8

2 Answers2

1

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

jfburdet
  • 313
  • 3
  • 8
0

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.

Cascabel
  • 479,068
  • 72
  • 370
  • 318
  • @jfburdet: Doesn't work how, exactly? And is the msysgit shell like sh/bash in terms of quoting? – Cascabel Jul 30 '10 at 17:12
  • I would add, even if I fully enclose generated file name by sed pipe, like this : git ls-files -s | sed "s-\t-&\"my figures/-" | sed "s-.*-&\"-" it still doesn't work... – jfburdet Jul 30 '10 at 18:29
  • In fact, the shell IS bash, but running under windows. I don't think It would be different under a real unix OS. – jfburdet Jul 30 '10 at 18:57
  • Tried using an ubuntu vm, got exactly same problem. – jfburdet Jul 30 '10 at 20:16