Subject: Re: Using filter-branch to move repo contents in subdirectory

From: Thomas Rast <[email-masked]>
Date: Thu, 29 Jul 2010 15:08:05 +0200

Adam Mercer wrote:
> $ git filter-branch --index-filter \
>     'git ls-files -s | sed "s-\t\"*-&sftlib/-" |
>         GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
>             git update-index --index-info &&
>     mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD
> Rewrite 223651f2ebd5d5d9341bcfc9e7cb6caaa3f4d171 (56/65)Ignoring path
> 00bootsftlib/

What OS is this?  You seem to have a 'sed' version where \t does not
match the horizontal tab character, or a shell that replaces the '\t'
inside a double-quoted string with simply 't'.

As a short-term fix, you can try to replace it with $(printf '\t')
which should always give a tab character.  You need to quote the '
though, so that's

  $ git filter-branch --index-filter \
      'git ls-files -s | sed "s-$(printf '\''\t'\'')\"*-&sftlib/-" |
          GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
              git update-index --index-info &&
      mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD

As for the actual issue: 'man 1p sed' on my system claims

        * The escape sequence '\n' shall match a <newline> embedded in the  pat-
          tern space. A literal <newline> shall not be used in the BRE of a con-
          text address or in the substitute function.

but does not mention \t at all, so I guess either that manpage is
wrong or GNU sed is not POSIX compliant even with --posix (where it
still treats \t as a tab).

-- 
Thomas Rast
trast@{inf,student}.ethz.ch