Skip to content

Commit

Permalink
filter-branch: add example to move everything into a subdirectory
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Jun 23, 2007
1 parent 0f2890a commit 55f22ff
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions git-filter-branch.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions t/t7003-filter-branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 55f22ff

Please sign in to comment.