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 <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Jun 21, 2007 at 18:05 UTC
55f22ff22e5ff6c21b50cf379ee946f9642fc3cb
2 files changed
+16
git-filter-branch.sh
+8
@@ -178,6 +178,14 @@
178
#
179
# git-filter-branch ... new-H C..H --not D
180
# 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
189
190
# Testsuite: TODO
191
t/t7003-filter-branch.sh
+8
@@ -99,4 +99,12 @@ test_expect_success 'subdirectory filter result looks okay' '
99
! git show sub:subdir
100
'
101
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
+
110
test_done