33test_description=' git filter-branch'
44. ./test-lib.sh
55
6- make_commit () {
7- lower=$( echo $1 | tr ' [A-Z]' ' [a-z]' )
8- echo $lower > $lower
9- git add $lower
10- test_tick
11- git commit -m $1
12- git tag $1
13- }
14-
156test_expect_success ' setup' '
16- make_commit A
17- make_commit B
18- git checkout -b branch B
19- make_commit D
20- mkdir dir
21- make_commit dir/D
22- make_commit E
23- git checkout master
24- make_commit C
25- git checkout branch
26- git merge C
27- git tag F
28- make_commit G
29- make_commit H
30- '
7+ test_commit A &&
8+ test_commit B &&
9+ git checkout -b branch B &&
10+ test_commit D &&
11+ mkdir dir &&
12+ test_commit dir/D &&
13+ test_commit E &&
14+ git checkout master &&
15+ test_commit C &&
16+ git checkout branch &&
17+ git merge C &&
18+ git tag F &&
19+ test_commit G &&
20+ test_commit H
21+ '
22+ # * (HEAD, branch) H
23+ # * G
24+ # * Merge commit 'C' into branch
25+ # |\
26+ # | * (master) C
27+ # * | E
28+ # * | dir/D
29+ # * | D
30+ # |/
31+ # * B
32+ # * A
33+
3134
3235H=$( git rev-parse H)
3336
@@ -65,33 +68,33 @@ test_expect_success 'Fail if commit filter fails' '
6568'
6669
6770test_expect_success ' rewrite, renaming a specific file' '
68- git filter-branch -f --tree-filter "mv d doh || :" HEAD
71+ git filter-branch -f --tree-filter "mv D.t doh || :" HEAD
6972'
7073
7174test_expect_success ' test that the file was renamed' '
72- test d = "$(git show HEAD:doh --)" &&
73- ! test -f d &&
75+ test D = "$(git show HEAD:doh --)" &&
76+ ! test -f D.t &&
7477 test -f doh &&
75- test d = "$(cat doh)"
78+ test D = "$(cat doh)"
7679'
7780
7881test_expect_success ' rewrite, renaming a specific directory' '
7982 git filter-branch -f --tree-filter "mv dir diroh || :" HEAD
8083'
8184
8285test_expect_success ' test that the directory was renamed' '
83- test dir/d = "$(git show HEAD:diroh/d --)" &&
86+ test dir/D = "$(git show HEAD:diroh/D.t --)" &&
8487 ! test -d dir &&
8588 test -d diroh &&
8689 ! test -d diroh/dir &&
87- test -f diroh/d &&
88- test dir/d = "$(cat diroh/d )"
90+ test -f diroh/D.t &&
91+ test dir/D = "$(cat diroh/D.t )"
8992'
9093
9194git tag oldD HEAD~4
9295test_expect_success ' rewrite one branch, keeping a side branch' '
9396 git branch modD oldD &&
94- git filter-branch -f --tree-filter "mv b boh || :" D..modD
97+ git filter-branch -f --tree-filter "mv B.t boh || :" D..modD
9598'
9699
97100test_expect_success ' common ancestor is still common (unchanged)' '
@@ -104,13 +107,13 @@ test_expect_success 'filter subdirectory only' '
104107 git add subdir/new &&
105108 test_tick &&
106109 git commit -m "subdir" &&
107- echo H > a &&
110+ echo H > A.t &&
108111 test_tick &&
109- git commit -m "not subdir" a &&
112+ git commit -m "not subdir" A.t &&
110113 echo A > subdir/new &&
111114 test_tick &&
112115 git commit -m "again subdir" subdir/new &&
113- git rm a &&
116+ git rm A.t &&
114117 test_tick &&
115118 git commit -m "again not subdir" &&
116119 git branch sub &&
@@ -134,7 +137,7 @@ test_expect_success 'more setup' '
134137 git add subdir/new &&
135138 test_tick &&
136139 git commit -m "subdir on master" subdir/new &&
137- git rm a &&
140+ git rm A.t &&
138141 test_tick &&
139142 git commit -m "again subdir on master" &&
140143 git merge branch
@@ -283,8 +286,8 @@ test_expect_success 'Tag name filtering allows slashes in tag names' '
283286
284287test_expect_success ' Prune empty commits' '
285288 git rev-list HEAD > expect &&
286- make_commit to_remove &&
287- git filter-branch -f --index-filter "git update-index --remove to_remove" --prune-empty HEAD &&
289+ test_commit to_remove &&
290+ git filter-branch -f --index-filter "git update-index --remove to_remove.t " --prune-empty HEAD &&
288291 git rev-list HEAD > actual &&
289292 test_cmp expect actual
290293'
0 commit comments