Filter-branch's "move tree to subdirectory" example fails with BSD sed?
- From
Christopher Tiwald <christiwald@gmail.com>
- Date
- Apr 14, 2012, 16:00 UTC
- Message-ID
- <20120414160028.GD1012@gmail.com>
The "Move tree to subdirectory" example in the 'git filter-branch' manpage fails on Mac OSX 10.7.3, but succeeds on Ubuntu 10.04. I'm using git version 1.7.0.4, which happened to be the version installed on the Ubuntu VM I had laying around. I think it's a difference between 'sed' on the two systems.
The example:
git filter-branch --index-filter \
'git ls-files -s | sed "s-\t\"*-&newsubdir/-" |
GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
git update-index --index-info &&
mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEADDemonstrating the problem is with sed: git init "test" cd "test" mkdir -p subdirA/subdirB echo content > subdirA/subdirB/file git add . git commit -m "initial commit" git ls-files -s | sed "s-\t\"*-&newsubdir/-"
On Mac 10.7.3 the final command outputs: 100644 d95f3ad14dee633a758d2e331151e950dd13e4ed 0 subdirA/subdirB/file
On Ubuntu 10.04: 100644 d95f3ad14dee633a758d2e331151e950dd13e4ed 0 newsubdir/subdirA/subdirB/file
I can solve my immediate problem using Ubuntu, but is there a way we could rewrite the example to work on both systems? I'm afraid differences between BSD and GNU 'sed' are a bit beyond me.
-- Christopher Tiwald