git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Adam Mercer <ramercer@gmail.com>
Date
Jul 29, 2010, 13:15 UTC
Message-ID
<AANLkTin5sv8NQ_8NZkQpW9HG4zYZDZHNF80EWK8Km4Mr@mail.gmail.com>
In-Reply-To
<201007291508.05242.trast@student.ethz.ch>
On Thu, Jul 29, 2010 at 14:08, Thomas Rast <trast@student.ethz.ch> wrote:
Show 10 quoted lines
> 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?
This was on Mac OS X 10.6. Where sed is BSD sed.
Show 13 quoted lines
> 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
Thanks, that did the trick!
Show 9 quoted lines
> 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).
Also using the original command, but specifying GNU sed also does the trick.
Cheers
Adam
Previous: Thomas RastNext: Thomas Rast
Message 3 of 13 in “Using filter-branch to move repo contents in subdirectory”
  1. Adam MercerJul 29, 2010
  2. Thomas RastJul 29, 2010
  3. Adam MercerJul 29, 2010
  4. filter-branch tests/docs: avoid \t in sed regexesThomas Rast, Jul 29, 2010
  5. Tomas CarneckyJul 29, 2010
  6. Thomas RastJul 29, 2010
  7. Tomas CarneckyJul 29, 2010
  8. t7005: fix subdirectory-filter testThomas Rast, Jul 29, 2010
  9. Thomas RastJul 29, 2010
  10. Adam MercerAug 9, 2010
  11. Adam MercerAug 11, 2010
  12. Jeff KingAug 11, 2010
  13. Adam MercerAug 11, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.