{"thread":{"id":"24571","subject":"Using filter-branch to move repo contents in subdirectory","startedAt":"2010-07-29T12:37:38Z","lastAt":"2010-08-11T19:59:03Z","messageCount":13,"participants":["Adam Mercer","Thomas Rast","Tomas Carnecky","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"146707","messageId":"AANLkTik2dL5jrEjZe0LB6Y4_PEwRt-7t_5CG7gup3pnV@mail.gmail.com","threadId":"24571","inReplyTo":null,"subject":"Using filter-branch to move repo contents in subdirectory","fromName":"Adam Mercer","fromEmail":"ramercer@gmail.com","sentAt":"2010-07-29T12:37:38Z","receivedAt":"2010-07-29T12:37:38Z","isPatch":false,"sender":{"key":"ramercer@gmail.com","avatar":"https://gravatar.com/avatar/16dc719817f62b75075d529ce4ea992ee82bb1a08e45a3029797f39223d6ee64?d=mp&s=160"},"body":"Hi\n\nI'm trying to use git filter-branch to move all contents of a repo\ninto a subdirectory of the repo root. The git filter-branch man page\nhas the following example:\n\n       To move the whole tree into a subdirectory, or remove it from there:\n\n           git filter-branch --index-filter \\\n                   'git ls-files -s | sed \"s-\\t\\\"*-&newsubdir/-\" |\n                           GIT_INDEX_FILE=$GIT_INDEX_FILE.new \\\n                                   git update-index --index-info &&\n                    mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD\n\nSo I've been trying to use this, the original structure of the repo is:\n\n$ ls\n00boot                 SFTdumpall.c     debian\nMakefile.am            SFTdumpheader.c  ligodcc.cls\nREADME                 SFTvalidate.c    pdfdraftcopy.sty\nSCCB_2004_09_09        SFTwrite.c       run_validate.sh\nSFTReferenceLibrary.c  T040164.tex      sftreferencelibrary-2.2.tar.gz\nSFTReferenceLibrary.h  configure.in     sftreferencelibrary-2.3.tar.gz\n$\n\nand I want all this in a subdirectory call \"sftlib\", so using the\nexample from the manpage I ran:\n\n$ git filter-branch --index-filter \\\n    'git ls-files -s | sed \"s-\\t\\\"*-&sftlib/-\" |\n        GIT_INDEX_FILE=$GIT_INDEX_FILE.new \\\n            git update-index --index-info &&\n    mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD\nRewrite 223651f2ebd5d5d9341bcfc9e7cb6caaa3f4d171 (56/65)Ignoring path\n00bootsftlib/\nRewrite c979ee835ebb89408e2f5f345ddefbb4d8cd75f5 (57/65)Ignoring path\n00bootsftlib/\nRewrite 10037389e41fb4b4d04234ca2e302a7a491616d5 (58/65)Ignoring path\n00bootsftlib/\nRewrite 21b4c31a02c6b7718145d471ba20e6fa70eb30d0 (59/65)Ignoring path\n00bootsftlib/\nRewrite dc5cebbe14050f52f2effaa5eac4eb579dd440c3 (60/65)Ignoring path\n00bootsftlib/\nRewrite 3b83fdd19b5d674445f5263df8cb2fc35c3c0092 (61/65)Ignoring path\n00bootsftlib/\nRewrite 5246038ceeb2d28fba462076b62f3cf1b2b7e9ab (62/65)Ignoring path\n00bootsftlib/\nRewrite 0fd3256ff401b405c677e83db350ad41ee74ef0d (63/65)Ignoring path\n00bootsftlib/\nIgnoring path debian/compatsftlib/\nIgnoring path debian/copyrightsftlib/\nRewrite 9aca227c807658b951e81a6ca4460115b2fe8ccc (64/65)Ignoring path\n00bootsftlib/\nIgnoring path debian/compatsftlib/\nIgnoring path debian/copyrightsftlib/\nRewrite 00274be10e10920d84db145268d85faf1b06539f (65/65)Ignoring path\n00bootsftlib/\nIgnoring path debian/compatsftlib/\nIgnoring path debian/copyrightsftlib/\n\nRef 'refs/heads/to_merge' was rewritten\n$\n\nnow the directory structure is:\n\n$ ls\nMakefile.am  SCCB_2004_09_09        SFTReferenceLibrary.h\nSFTdumpheader.c   SFTwritsftlib    configure.in  ligodcc.cls\nrun_validatsftlib\nREADME       SFTReferenceLibrary.c  SFTdumpall.c\nSFTvalidatsftlib  T040164.tsftlib  debian        pdfdraftsftlib\nsftsftlib\n$\n\nwhich is clearly not what I'm wanting. What I am doing wrong here? As\nfar as I can I'm using the example from the man-page?\n\nCheers\n\nAdam\n"},{"id":"146708","messageId":"201007291508.05242.trast@student.ethz.ch","threadId":"24571","inReplyTo":"AANLkTik2dL5jrEjZe0LB6Y4_PEwRt-7t_5CG7gup3pnV@mail.gmail.com","subject":"Re: Using filter-branch to move repo contents in subdirectory","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-07-29T13:08:05Z","receivedAt":"2010-07-29T13:08:05Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Adam Mercer wrote:\n> $ git filter-branch --index-filter \\\n>     'git ls-files -s | sed \"s-\\t\\\"*-&sftlib/-\" |\n>         GIT_INDEX_FILE=$GIT_INDEX_FILE.new \\\n>             git update-index --index-info &&\n>     mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD\n> Rewrite 223651f2ebd5d5d9341bcfc9e7cb6caaa3f4d171 (56/65)Ignoring path\n> 00bootsftlib/\n\nWhat OS is this?  You seem to have a 'sed' version where \\t does not\nmatch the horizontal tab character, or a shell that replaces the '\\t'\ninside a double-quoted string with simply 't'.\n\nAs a short-term fix, you can try to replace it with $(printf '\\t')\nwhich should always give a tab character.  You need to quote the '\nthough, so that's\n\n  $ git filter-branch --index-filter \\\n      'git ls-files -s | sed \"s-$(printf '\\''\\t'\\'')\\\"*-&sftlib/-\" |\n          GIT_INDEX_FILE=$GIT_INDEX_FILE.new \\\n              git update-index --index-info &&\n      mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD\n\n\nAs for the actual issue: 'man 1p sed' on my system claims\n\n        * The escape sequence '\\n' shall match a <newline> embedded in the  pat-\n          tern space. A literal <newline> shall not be used in the BRE of a con-\n          text address or in the substitute function.\n\nbut does not mention \\t at all, so I guess either that manpage is\nwrong or GNU sed is not POSIX compliant even with --posix (where it\nstill treats \\t as a tab).\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"146709","messageId":"AANLkTin5sv8NQ_8NZkQpW9HG4zYZDZHNF80EWK8Km4Mr@mail.gmail.com","threadId":"24571","inReplyTo":"201007291508.05242.trast@student.ethz.ch","subject":"Re: Using filter-branch to move repo contents in subdirectory","fromName":"Adam Mercer","fromEmail":"ramercer@gmail.com","sentAt":"2010-07-29T13:15:31Z","receivedAt":"2010-07-29T13:15:31Z","isPatch":false,"sender":{"key":"ramercer@gmail.com","avatar":"https://gravatar.com/avatar/16dc719817f62b75075d529ce4ea992ee82bb1a08e45a3029797f39223d6ee64?d=mp&s=160"},"body":"On Thu, Jul 29, 2010 at 14:08, Thomas Rast <trast@student.ethz.ch> wrote:\n> Adam Mercer wrote:\n>> $ git filter-branch --index-filter \\\n>>     'git ls-files -s | sed \"s-\\t\\\"*-&sftlib/-\" |\n>>         GIT_INDEX_FILE=$GIT_INDEX_FILE.new \\\n>>             git update-index --index-info &&\n>>     mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD\n>> Rewrite 223651f2ebd5d5d9341bcfc9e7cb6caaa3f4d171 (56/65)Ignoring path\n>> 00bootsftlib/\n>\n> What OS is this?\n\nThis was on Mac OS X 10.6. Where sed is BSD sed.\n\n> You seem to have a 'sed' version where \\t does not\n> match the horizontal tab character, or a shell that replaces the '\\t'\n> inside a double-quoted string with simply 't'.\n>\n> As a short-term fix, you can try to replace it with $(printf '\\t')\n> which should always give a tab character.  You need to quote the '\n> though, so that's\n>\n>  $ git filter-branch --index-filter \\\n>      'git ls-files -s | sed \"s-$(printf '\\''\\t'\\'')\\\"*-&sftlib/-\" |\n>          GIT_INDEX_FILE=$GIT_INDEX_FILE.new \\\n>              git update-index --index-info &&\n>      mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD\n\nThanks, that did the trick!\n\n> As for the actual issue: 'man 1p sed' on my system claims\n>\n>        * The escape sequence '\\n' shall match a <newline> embedded in the  pat-\n>          tern space. A literal <newline> shall not be used in the BRE of a con-\n>          text address or in the substitute function.\n>\n> but does not mention \\t at all, so I guess either that manpage is\n> wrong or GNU sed is not POSIX compliant even with --posix (where it\n> still treats \\t as a tab).\n\nAlso using the original command, but specifying GNU sed also does the trick.\n\nCheers\n\nAdam\n"},{"id":"146710","messageId":"0bb511ca2d155ea7e37850a78375da1803032d6c.1280409717.git.trast@student.ethz.ch","threadId":"24571","inReplyTo":"AANLkTin5sv8NQ_8NZkQpW9HG4zYZDZHNF80EWK8Km4Mr@mail.gmail.com","subject":"[PATCH] filter-branch tests/docs: avoid \\t in sed regexes","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-07-29T13:24:30Z","receivedAt":"2010-07-29T13:24:30Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Using \\t to represent a tab character is not portable beyond GNU sed\n(see e.g. GNU sed's info pages).  Use printf to generate the tab\ninstead.\n\nSigned-off-by: Thomas Rast <trast@student.ethz.ch>\n---\n\n Adam Mercer wrote:\n> > What OS is this?\n> This was on Mac OS X 10.6. Where sed is BSD sed.\n\nThat's very funny however, since it means that nobody should ever have\nhad a successful test run on OS X with the preinstalled tools.  What\ngives?\n\n\n Documentation/git-filter-branch.txt |    3 ++-\n t/t7003-filter-branch.sh            |    3 ++-\n 2 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt\nindex 020028c..7e3ff8e 100644\n--- a/Documentation/git-filter-branch.txt\n+++ b/Documentation/git-filter-branch.txt\n@@ -357,8 +357,9 @@ git filter-branch ... D..H --not C\n To move the whole tree into a subdirectory, or remove it from there:\n \n ---------------------------------------------------------------\n+export TAB=\"$(printf '\\t')\"\n git filter-branch --index-filter \\\n-\t'git ls-files -s | sed \"s-\\t\\\"*-&newsubdir/-\" |\n+\t'git ls-files -s | sed \"s-$TAB\\\"*-&newsubdir/-\" |\n \t\tGIT_INDEX_FILE=$GIT_INDEX_FILE.new \\\n \t\t\tgit update-index --index-info &&\n \t mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD\ndiff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh\nindex 0da13a8..e90da6d 100755\n--- a/t/t7003-filter-branch.sh\n+++ b/t/t7003-filter-branch.sh\n@@ -140,10 +140,11 @@ test_expect_success 'more setup' '\n \tgit merge branch\n '\n \n+export TAB=\"$(printf '\\t')\"\n test_expect_success 'use index-filter to move into a subdirectory' '\n \tgit branch directorymoved &&\n \tgit filter-branch -f --index-filter \\\n-\t\t \"git ls-files -s | sed \\\"s-\\\\t-&newsubdir/-\\\" |\n+\t\t \"git ls-files -s | sed \\\"s-$TAB-&newsubdir/-\\\" |\n \t          GIT_INDEX_FILE=\\$GIT_INDEX_FILE.new \\\n \t\t\tgit update-index --index-info &&\n \t\t  mv \\\"\\$GIT_INDEX_FILE.new\\\" \\\"\\$GIT_INDEX_FILE\\\"\" directorymoved &&\n-- \n1.7.2.1.342.g676a4\n"},{"id":"146712","messageId":"4C519498.3000702@dbservice.com","threadId":"24571","inReplyTo":"0bb511ca2d155ea7e37850a78375da1803032d6c.1280409717.git.trast@student.ethz.ch","subject":"Re: [PATCH] filter-branch tests/docs: avoid \\t in sed regexes","fromName":"Tomas Carnecky","fromEmail":"tom@dbservice.com","sentAt":"2010-07-29T14:47:52Z","receivedAt":"2010-07-29T14:47:52Z","isPatch":true,"sender":{"key":"tom@dbservice.com","avatar":"https://gravatar.com/avatar/900a300bdd1a8bbe086008ad78210bbee2ad2803b7d50a5cba04c1e9404bd6d2?d=mp&s=160"},"body":"On 7/29/10 3:24 PM, Thomas Rast wrote:\n> Using \\t to represent a tab character is not portable beyond GNU sed\n> (see e.g. GNU sed's info pages).  Use printf to generate the tab\n> instead.\n> \n> Signed-off-by: Thomas Rast <trast@student.ethz.ch>\n> ---\n> \n>  Adam Mercer wrote:\n>>> What OS is this?\n>> This was on Mac OS X 10.6. Where sed is BSD sed.\n> \n> That's very funny however, since it means that nobody should ever have\n> had a successful test run on OS X with the preinstalled tools.  What\n> gives?\n\nv1.7.2-rc1 on 10.6:\n\nfixed   3\nsuccess 6328\nfailed  0\nbroken  21\ntotal   6355\n\n*** t7003-filter-branch.sh ***\n*   ok 1: setup\n*   ok 2: rewrite identically\n*   ok 3: result is really identical\n*   ok 4: rewrite bare repository identically\n*   ok 5: result is really identical\n*   ok 6: correct GIT_DIR while using -d\n*   ok 7: Fail if commit filter fails\n*   ok 8: rewrite, renaming a specific file\n*   ok 9: test that the file was renamed\n*   ok 10: rewrite, renaming a specific directory\n*   ok 11: test that the directory was renamed\n*   ok 12: rewrite one branch, keeping a side branch\n*   ok 13: common ancestor is still common (unchanged)\n*   ok 14: filter subdirectory only\n*   ok 15: subdirectory filter result looks okay\n*   ok 16: more setup\n*   ok 17: use index-filter to move into a subdirectory\n*   ok 18: stops when msg filter fails\n*   ok 19: author information is preserved\n*   ok 20: remove a certain author's commits\n*   ok 21: barf on invalid name\n*   ok 22: \"map\" works in commit filter\n*   ok 23: Name needing quotes\n*   ok 24: Subdirectory filter with disappearing trees\n*   ok 25: Tag name filtering retains tag message\n*   ok 26: Tag name filtering strips gpg signature\n*   ok 27: Tag name filtering allows slashes in tag names\n*   ok 28: Prune empty commits\n*   ok 29: --remap-to-ancestor with filename filters\n*   ok 30: setup submodule\n*   ok 31: rewrite submodule with another content\n*   ok 32: replace submodule revision\n"},{"id":"146714","messageId":"201007291652.52506.trast@student.ethz.ch","threadId":"24571","inReplyTo":"4C519498.3000702@dbservice.com","subject":"Re: [PATCH] filter-branch tests/docs: avoid \\t in sed regexes","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-07-29T14:52:52Z","receivedAt":"2010-07-29T14:52:52Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Tomas Carnecky wrote:\n> On 7/29/10 3:24 PM, Thomas Rast wrote:\n> > Using \\t to represent a tab character is not portable beyond GNU sed\n> > (see e.g. GNU sed's info pages).  Use printf to generate the tab\n> > instead.\n[...]\n> > That's very funny however, since it means that nobody should ever have\n> > had a successful test run on OS X with the preinstalled tools.  What\n> > gives?\n[...]\n> *** t7003-filter-branch.sh ***\n> *   ok 17: use index-filter to move into a subdirectory\n\nOh, I know.  The test isn't correct, it should be something like the\npatch below.  Otherwise a failure in git-diff (namely that\ndirectorymoved:newsubdir is invalid) is never detected, and since the\noutput in this case is empty, also the test -z succeeds.  Can you\napply that and see if it makes the test fail for you?\n\ndiff --git i/t/t7003-filter-branch.sh w/t/t7003-filter-branch.sh\nindex e90da6d..a8e0c48 100755\n--- i/t/t7003-filter-branch.sh\n+++ w/t/t7003-filter-branch.sh\n@@ -148,7 +148,9 @@ test_expect_success 'use index-filter to move into a subdirectory' '\n \t          GIT_INDEX_FILE=\\$GIT_INDEX_FILE.new \\\n \t\t\tgit update-index --index-info &&\n \t\t  mv \\\"\\$GIT_INDEX_FILE.new\\\" \\\"\\$GIT_INDEX_FILE\\\"\" directorymoved &&\n-\ttest -z \"$(git diff HEAD directorymoved:newsubdir)\"'\n+\tgit diff HEAD directorymoved:newsubdir > actual &&\n+\ttest ! -s actual\n+'\n \n test_expect_success 'stops when msg filter fails' '\n \told=$(git rev-parse HEAD) &&\n\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"146715","messageId":"4C519810.6090108@dbservice.com","threadId":"24571","inReplyTo":"201007291652.52506.trast@student.ethz.ch","subject":"Re: [PATCH] filter-branch tests/docs: avoid \\t in sed regexes","fromName":"Tomas Carnecky","fromEmail":"tom@dbservice.com","sentAt":"2010-07-29T15:02:40Z","receivedAt":"2010-07-29T15:02:40Z","isPatch":true,"sender":{"key":"tom@dbservice.com","avatar":"https://gravatar.com/avatar/900a300bdd1a8bbe086008ad78210bbee2ad2803b7d50a5cba04c1e9404bd6d2?d=mp&s=160"},"body":"On 7/29/10 4:52 PM, Thomas Rast wrote:\n> Tomas Carnecky wrote:\n>> *** t7003-filter-branch.sh ***\n>> *   ok 17: use index-filter to move into a subdirectory\n> \n> Oh, I know.  The test isn't correct, it should be something like the\n> patch below.  Otherwise a failure in git-diff (namely that\n> directorymoved:newsubdir is invalid) is never detected, and since the\n> output in this case is empty, also the test -z succeeds.  Can you\n> apply that and see if it makes the test fail for you?\n> \n> diff --git i/t/t7003-filter-branch.sh w/t/t7003-filter-branch.sh\n> index e90da6d..a8e0c48 100755\n> --- i/t/t7003-filter-branch.sh\n> +++ w/t/t7003-filter-branch.sh\n> @@ -148,7 +148,9 @@ test_expect_success 'use index-filter to move into a subdirectory' '\n>  \t          GIT_INDEX_FILE=\\$GIT_INDEX_FILE.new \\\n>  \t\t\tgit update-index --index-info &&\n>  \t\t  mv \\\"\\$GIT_INDEX_FILE.new\\\" \\\"\\$GIT_INDEX_FILE\\\"\" directorymoved &&\n> -\ttest -z \"$(git diff HEAD directorymoved:newsubdir)\"'\n> +\tgit diff HEAD directorymoved:newsubdir > actual &&\n> +\ttest ! -s actual\n> +'\n>  \n>  test_expect_success 'stops when msg filter fails' '\n>  \told=$(git rev-parse HEAD) &&\n\nNow the test fails. And with the other patch applied on top of it, the\ntest passes again.\n\ntom\n"},{"id":"146716","messageId":"8fe9ee3cfe2404b719fc0464db9a34c09175052a.1280416055.git.trast@student.ethz.ch","threadId":"24571","inReplyTo":"4C519810.6090108@dbservice.com","subject":"[PATCH] t7005: fix subdirectory-filter test","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-07-29T15:10:22Z","receivedAt":"2010-07-29T15:10:22Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"The test would not fail if the filtering failed to do anything, since\nin\n\n  test -z \"$(git diff HEAD directorymoved:newsubdir)\"'\n\n'directorymoved:newsubdir' is not valid, so git-diff fails without\nprinting anything on stdout.  But then the exit status of git-diff is\nlost, whereas test -z \"\" succeeds.\n\nUse 'git diff --exit-code' instead, which does the right thing and has\nthe added bonus of showing the differences if there are any.\n\nSigned-off-by: Thomas Rast <trast@student.ethz.ch>\n---\n\nTomas Carnecky wrote:\n> Now the test fails. And with the other patch applied on top of it, the\n> test passes again.\n\nOk.  Here's a slightly nicer solution, let's add this on top of the\nearlier patch.\n\n t/t7003-filter-branch.sh |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh\nindex e90da6d..84c2612 100755\n--- a/t/t7003-filter-branch.sh\n+++ b/t/t7003-filter-branch.sh\n@@ -148,7 +148,8 @@ test_expect_success 'use index-filter to move into a subdirectory' '\n \t          GIT_INDEX_FILE=\\$GIT_INDEX_FILE.new \\\n \t\t\tgit update-index --index-info &&\n \t\t  mv \\\"\\$GIT_INDEX_FILE.new\\\" \\\"\\$GIT_INDEX_FILE\\\"\" directorymoved &&\n-\ttest -z \"$(git diff HEAD directorymoved:newsubdir)\"'\n+\tgit diff --exit-code HEAD directorymoved:newsubdir\n+'\n \n test_expect_success 'stops when msg filter fails' '\n \told=$(git rev-parse HEAD) &&\n-- \n1.7.2.1.342.g676a4\n"},{"id":"146717","messageId":"201007291712.09639.trast@student.ethz.ch","threadId":"24571","inReplyTo":"8fe9ee3cfe2404b719fc0464db9a34c09175052a.1280416055.git.trast@student.ethz.ch","subject":"Re: [PATCH] t7005: fix subdirectory-filter test","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-07-29T15:12:09Z","receivedAt":"2010-07-29T15:12:09Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Thomas Rast wrote:\n> t7005: fix subdirectory-filter test\n\nBah, this subject is wrong on two counts.  It should be something like\n\n  t7003: fix move-to-subdirectory test\n\ninstead.  Sorry for the noise.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"147538","messageId":"AANLkTi=TeJvF+swpMWddDtA7jh4XWedQ+FjigEdRYkx_@mail.gmail.com","threadId":"24571","inReplyTo":"AANLkTik2dL5jrEjZe0LB6Y4_PEwRt-7t_5CG7gup3pnV@mail.gmail.com","subject":"Re: Using filter-branch to move repo contents in subdirectory","fromName":"Adam Mercer","fromEmail":"ramercer@gmail.com","sentAt":"2010-08-09T19:36:19Z","receivedAt":"2010-08-09T19:36:19Z","isPatch":false,"sender":{"key":"ramercer@gmail.com","avatar":"https://gravatar.com/avatar/16dc719817f62b75075d529ce4ea992ee82bb1a08e45a3029797f39223d6ee64?d=mp&s=160"},"body":"On Thu, Jul 29, 2010 at 07:37, Adam Mercer <ramercer@gmail.com> wrote:\n\n> I'm trying to use git filter-branch to move all contents of a repo\n> into a subdirectory of the repo root. The git filter-branch man page\n> has the following example:\n>\n>       To move the whole tree into a subdirectory, or remove it from there:\n>\n>           git filter-branch --index-filter \\\n>                   'git ls-files -s | sed \"s-\\t\\\"*-&newsubdir/-\" |\n>                           GIT_INDEX_FILE=$GIT_INDEX_FILE.new \\\n>                                   git update-index --index-info &&\n>                    mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD\n\nI'm trying to do this with another repo now and am getting a different\nerror message:\n\n$ git filter-branch --index-filter \\\n    'git ls-files -s | gsed \"s-\\t\\\"*-&sftlib/-\" |\n        GIT_INDEX_FILE=$GIT_INDEX_FILE.new \\\n            git update-index --index-info &&\n    mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD\nRewrite b3100fb24a7eb2f349801f3b87cf995dc3d14bba (1/44)mv:\n/Users/ram/git/eah2/.git-rewrite/t/../index.new: No such file or\ndirectory\nindex filter failed: git ls-files -s | gsed \"s-\\t\\\"*-&sftlib/-\" |\nGIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info && mv\n$GIT_INDEX_FILE.new $GIT_INDEX_FILE\n$\n\nAny ideas?\n\nThis is on Mac OS X 10.6.4, with git-1.7.2.1, and GNU sed 4.2.1\n\nCheers\n\nAdam\n"},{"id":"147767","messageId":"AANLkTimu+V8zJeBV65nhqw0zaQHVHzZZahw2q-20SaWO@mail.gmail.com","threadId":"24571","inReplyTo":"AANLkTi=TeJvF+swpMWddDtA7jh4XWedQ+FjigEdRYkx_@mail.gmail.com","subject":"Re: Using filter-branch to move repo contents in subdirectory","fromName":"Adam Mercer","fromEmail":"ramercer@gmail.com","sentAt":"2010-08-11T15:01:15Z","receivedAt":"2010-08-11T15:01:15Z","isPatch":false,"sender":{"key":"ramercer@gmail.com","avatar":"https://gravatar.com/avatar/16dc719817f62b75075d529ce4ea992ee82bb1a08e45a3029797f39223d6ee64?d=mp&s=160"},"body":"On Mon, Aug 9, 2010 at 14:36, Adam Mercer <ramercer@gmail.com> wrote:\n\n> I'm trying to do this with another repo now and am getting a different\n> error message:\n>\n> $ git filter-branch --index-filter \\\n>    'git ls-files -s | gsed \"s-\\t\\\"*-&sftlib/-\" |\n>        GIT_INDEX_FILE=$GIT_INDEX_FILE.new \\\n>            git update-index --index-info &&\n>    mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD\n> Rewrite b3100fb24a7eb2f349801f3b87cf995dc3d14bba (1/44)mv:\n> /Users/ram/git/eah2/.git-rewrite/t/../index.new: No such file or\n> directory\n> index filter failed: git ls-files -s | gsed \"s-\\t\\\"*-&sftlib/-\" |\n> GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info && mv\n> $GIT_INDEX_FILE.new $GIT_INDEX_FILE\n> $\n>\n> Any ideas?\n>\n> This is on Mac OS X 10.6.4, with git-1.7.2.1, and GNU sed 4.2.1\n\nAnyone?\n\nCheers\n\nAdam\n"},{"id":"147820","messageId":"20100811193214.GB8106@coredump.intra.peff.net","threadId":"24571","inReplyTo":"AANLkTimu+V8zJeBV65nhqw0zaQHVHzZZahw2q-20SaWO@mail.gmail.com","subject":"Re: Using filter-branch to move repo contents in subdirectory","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-08-11T19:32:14Z","receivedAt":"2010-08-11T19:32:14Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Aug 11, 2010 at 10:01:15AM -0500, Adam Mercer wrote:\n\n> On Mon, Aug 9, 2010 at 14:36, Adam Mercer <ramercer@gmail.com> wrote:\n> \n> > I'm trying to do this with another repo now and am getting a different\n> > error message:\n> >\n> > $ git filter-branch --index-filter \\\n> >    'git ls-files -s | gsed \"s-\\t\\\"*-&sftlib/-\" |\n> >        GIT_INDEX_FILE=$GIT_INDEX_FILE.new \\\n> >            git update-index --index-info &&\n> >    mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD\n> > Rewrite b3100fb24a7eb2f349801f3b87cf995dc3d14bba (1/44)mv:\n> > /Users/ram/git/eah2/.git-rewrite/t/../index.new: No such file or\n> > directory\n> > index filter failed: git ls-files -s | gsed \"s-\\t\\\"*-&sftlib/-\" |\n> > GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info && mv\n> > $GIT_INDEX_FILE.new $GIT_INDEX_FILE\n> > $\n> >\n> > Any ideas?\n> >\n> > This is on Mac OS X 10.6.4, with git-1.7.2.1, and GNU sed 4.2.1\n> \n> Anyone?\n\nIt looks like git-update-index will not create $GIT_INDEX_FILE at all if\nyou have no actual input lines to --index-info. So perhaps you have some\ncommit in your repo that has no actual content in it. Either that or\nfor some reason your \"ls-files -s | gsed\" invocation is producing no\noutput.\n\nTry adding a \"touch $GIT_INDEX_FILE.new\" at the beginning of your index\nfilter and see if that helps. Then the file will always exist to be\nmoved, even if we write nothing to it. If it works, then problem solved.\nIf you get a repo full of empty commits, then something is wrong with\nyour gsed pipeline.\n\n-Peff\n"},{"id":"147826","messageId":"AANLkTi=G=oWaQ4PvjbkfEs2FUXgbKr3s+hWy8azSZsAH@mail.gmail.com","threadId":"24571","inReplyTo":"20100811193214.GB8106@coredump.intra.peff.net","subject":"Re: Using filter-branch to move repo contents in subdirectory","fromName":"Adam Mercer","fromEmail":"ramercer@gmail.com","sentAt":"2010-08-11T19:59:03Z","receivedAt":"2010-08-11T19:59:03Z","isPatch":false,"sender":{"key":"ramercer@gmail.com","avatar":"https://gravatar.com/avatar/16dc719817f62b75075d529ce4ea992ee82bb1a08e45a3029797f39223d6ee64?d=mp&s=160"},"body":"On Wed, Aug 11, 2010 at 14:32, Jeff King <peff@peff.net> wrote:\n\n> It looks like git-update-index will not create $GIT_INDEX_FILE at all if\n> you have no actual input lines to --index-info. So perhaps you have some\n> commit in your repo that has no actual content in it. Either that or\n> for some reason your \"ls-files -s | gsed\" invocation is producing no\n> output.\n\nYep, that was the problem. I'd been modifying the history with several\ngit filter-branch calls and the initial commit in the repo was empty.\nGetting rid of this initial empty commit allowed the command to run.\n\nCheers\n\nAdam\n"}]}