From 55f22ff22e5ff6c21b50cf379ee946f9642fc3cb Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 21 Jun 2007 18:05:30 +0100 Subject: [PATCH] filter-branch: add example to move everything into a subdirectory This is based on Jeff King's example in 20070621130137.GB4487@coredump.intra.peff.net Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- git-filter-branch.sh | 8 ++++++++ t/t7003-filter-branch.sh | 8 ++++++++ 2 files changed, 16 insertions(+) mode change 100755 => 100644 git-filter-branch.sh diff --git a/git-filter-branch.sh b/git-filter-branch.sh old mode 100755 new mode 100644 index bfd118cd3b..8fa5ce6467 --- a/git-filter-branch.sh +++ b/git-filter-branch.sh @@ -178,6 +178,14 @@ # # git-filter-branch ... new-H C..H --not D # git-filter-branch ... new-H D..H --not C +# +# To move the whole tree into a subdirectory, or remove it from there: +# +# 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' directorymoved # Testsuite: TODO diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh index 0fabe4904f..f00c262e45 100755 --- a/t/t7003-filter-branch.sh +++ b/t/t7003-filter-branch.sh @@ -99,4 +99,12 @@ test_expect_success 'subdirectory filter result looks okay' ' ! git show sub:subdir ' +test_expect_success 'use index-filter to move into a subdirectory' ' + 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" directorymoved && + test -z "$(git diff HEAD directorymoved:newsubdir)"' + test_done -- 2.11.4.GIT