Merge branch 'bg/fix-t7003'

* bg/fix-t7003:
  t7003: Use test_commit instead of custom function
This commit is contained in:
Junio C Hamano 2010-09-16 07:43:41 -07:00
commit 02567e88ee

View File

@ -3,31 +3,34 @@
test_description='git filter-branch' test_description='git filter-branch'
. ./test-lib.sh . ./test-lib.sh
make_commit () {
lower=$(echo $1 | tr '[A-Z]' '[a-z]')
echo $lower > $lower
git add $lower
test_tick
git commit -m $1
git tag $1
}
test_expect_success 'setup' ' test_expect_success 'setup' '
make_commit A test_commit A &&
make_commit B test_commit B &&
git checkout -b branch B git checkout -b branch B &&
make_commit D test_commit D &&
mkdir dir mkdir dir &&
make_commit dir/D test_commit dir/D &&
make_commit E test_commit E &&
git checkout master git checkout master &&
make_commit C test_commit C &&
git checkout branch git checkout branch &&
git merge C git merge C &&
git tag F git tag F &&
make_commit G test_commit G &&
make_commit H test_commit H
' '
# * (HEAD, branch) H
# * G
# * Merge commit 'C' into branch
# |\
# | * (master) C
# * | E
# * | dir/D
# * | D
# |/
# * B
# * A
H=$(git rev-parse H) H=$(git rev-parse H)
@ -65,14 +68,14 @@ test_expect_success 'Fail if commit filter fails' '
' '
test_expect_success 'rewrite, renaming a specific file' ' test_expect_success 'rewrite, renaming a specific file' '
git filter-branch -f --tree-filter "mv d doh || :" HEAD git filter-branch -f --tree-filter "mv D.t doh || :" HEAD
' '
test_expect_success 'test that the file was renamed' ' test_expect_success 'test that the file was renamed' '
test d = "$(git show HEAD:doh --)" && test D = "$(git show HEAD:doh --)" &&
! test -f d && ! test -f D.t &&
test -f doh && test -f doh &&
test d = "$(cat doh)" test D = "$(cat doh)"
' '
test_expect_success 'rewrite, renaming a specific directory' ' test_expect_success 'rewrite, renaming a specific directory' '
@ -80,18 +83,18 @@ test_expect_success 'rewrite, renaming a specific directory' '
' '
test_expect_success 'test that the directory was renamed' ' test_expect_success 'test that the directory was renamed' '
test dir/d = "$(git show HEAD:diroh/d --)" && test dir/D = "$(git show HEAD:diroh/D.t --)" &&
! test -d dir && ! test -d dir &&
test -d diroh && test -d diroh &&
! test -d diroh/dir && ! test -d diroh/dir &&
test -f diroh/d && test -f diroh/D.t &&
test dir/d = "$(cat diroh/d)" test dir/D = "$(cat diroh/D.t)"
' '
git tag oldD HEAD~4 git tag oldD HEAD~4
test_expect_success 'rewrite one branch, keeping a side branch' ' test_expect_success 'rewrite one branch, keeping a side branch' '
git branch modD oldD && git branch modD oldD &&
git filter-branch -f --tree-filter "mv b boh || :" D..modD git filter-branch -f --tree-filter "mv B.t boh || :" D..modD
' '
test_expect_success 'common ancestor is still common (unchanged)' ' test_expect_success 'common ancestor is still common (unchanged)' '
@ -104,13 +107,13 @@ test_expect_success 'filter subdirectory only' '
git add subdir/new && git add subdir/new &&
test_tick && test_tick &&
git commit -m "subdir" && git commit -m "subdir" &&
echo H > a && echo H > A.t &&
test_tick && test_tick &&
git commit -m "not subdir" a && git commit -m "not subdir" A.t &&
echo A > subdir/new && echo A > subdir/new &&
test_tick && test_tick &&
git commit -m "again subdir" subdir/new && git commit -m "again subdir" subdir/new &&
git rm a && git rm A.t &&
test_tick && test_tick &&
git commit -m "again not subdir" && git commit -m "again not subdir" &&
git branch sub && git branch sub &&
@ -134,7 +137,7 @@ test_expect_success 'more setup' '
git add subdir/new && git add subdir/new &&
test_tick && test_tick &&
git commit -m "subdir on master" subdir/new && git commit -m "subdir on master" subdir/new &&
git rm a && git rm A.t &&
test_tick && test_tick &&
git commit -m "again subdir on master" && git commit -m "again subdir on master" &&
git merge branch git merge branch
@ -283,8 +286,8 @@ test_expect_success 'Tag name filtering allows slashes in tag names' '
test_expect_success 'Prune empty commits' ' test_expect_success 'Prune empty commits' '
git rev-list HEAD > expect && git rev-list HEAD > expect &&
make_commit to_remove && test_commit to_remove &&
git filter-branch -f --index-filter "git update-index --remove to_remove" --prune-empty HEAD && git filter-branch -f --index-filter "git update-index --remove to_remove.t" --prune-empty HEAD &&
git rev-list HEAD > actual && git rev-list HEAD > actual &&
test_cmp expect actual test_cmp expect actual
' '