git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Filter-branch's "move tree to subdirectory" example fails with BSD sed?
@ 2012-04-14 16:00 Christopher Tiwald
  2012-04-14 19:25 ` Johannes Sixt
  0 siblings, 1 reply; 9+ messages in thread
From: Christopher Tiwald @ 2012-04-14 16:00 UTC (permalink / raw)
  To: git

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' HEAD

Demonstrating 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-04-17 18:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-14 16:00 Filter-branch's "move tree to subdirectory" example fails with BSD sed? Christopher Tiwald
2012-04-14 19:25 ` Johannes Sixt
2012-04-16 15:27   ` Jeff King
2012-04-16 16:02     ` [RFC/PATCH 1/2] update-index: add --clear option Jeff King
2012-04-16 21:48       ` Christopher Tiwald
2012-04-17 18:36         ` Christopher Tiwald
2012-04-16 16:03     ` [RFC/PATCH 2/2] docs/filter-branch: clean up newsubdir example Jeff King
2012-04-16 17:03     ` Filter-branch's "move tree to subdirectory" example fails with BSD sed? Junio C Hamano
2012-04-16 17:13       ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).