Skip to content

Commit 55f22ff

Browse files
dschogitster
authored andcommitted
filter-branch: add example to move everything into a subdirectory
This is based on Jeff King's example in [email protected] Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0f2890a commit 55f22ff

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

git-filter-branch.sh

100755100644
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,14 @@
178178
#
179179
# git-filter-branch ... new-H C..H --not D
180180
# git-filter-branch ... new-H D..H --not C
181+
#
182+
# To move the whole tree into a subdirectory, or remove it from there:
183+
#
184+
# git-filter-branch --index-filter \
185+
# 'git-ls-files -s | sed "s-\t-&newsubdir/-" |
186+
# GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
187+
# git-update-index --index-info &&
188+
# mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' directorymoved
181189

182190
# Testsuite: TODO
183191

t/t7003-filter-branch.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,12 @@ test_expect_success 'subdirectory filter result looks okay' '
9999
! git show sub:subdir
100100
'
101101

102+
test_expect_success 'use index-filter to move into a subdirectory' '
103+
git-filter-branch --index-filter \
104+
"git-ls-files -s | sed \"s-\\t-&newsubdir/-\" |
105+
GIT_INDEX_FILE=\$GIT_INDEX_FILE.new \
106+
git-update-index --index-info &&
107+
mv \$GIT_INDEX_FILE.new \$GIT_INDEX_FILE" directorymoved &&
108+
test -z "$(git diff HEAD directorymoved:newsubdir)"'
109+
102110
test_done

0 commit comments

Comments
 (0)