3
3
test_description=' git filter-branch'
4
4
. ./test-lib.sh
5
5
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
-
15
6
test_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
+
31
34
32
35
H=$( git rev-parse H)
33
36
@@ -65,33 +68,33 @@ test_expect_success 'Fail if commit filter fails' '
65
68
'
66
69
67
70
test_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
69
72
'
70
73
71
74
test_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 &&
74
77
test -f doh &&
75
- test d = "$(cat doh)"
78
+ test D = "$(cat doh)"
76
79
'
77
80
78
81
test_expect_success ' rewrite, renaming a specific directory' '
79
82
git filter-branch -f --tree-filter "mv dir diroh || :" HEAD
80
83
'
81
84
82
85
test_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 --)" &&
84
87
! test -d dir &&
85
88
test -d diroh &&
86
89
! 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 )"
89
92
'
90
93
91
94
git tag oldD HEAD~4
92
95
test_expect_success ' rewrite one branch, keeping a side branch' '
93
96
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
95
98
'
96
99
97
100
test_expect_success ' common ancestor is still common (unchanged)' '
@@ -104,13 +107,13 @@ test_expect_success 'filter subdirectory only' '
104
107
git add subdir/new &&
105
108
test_tick &&
106
109
git commit -m "subdir" &&
107
- echo H > a &&
110
+ echo H > A.t &&
108
111
test_tick &&
109
- git commit -m "not subdir" a &&
112
+ git commit -m "not subdir" A.t &&
110
113
echo A > subdir/new &&
111
114
test_tick &&
112
115
git commit -m "again subdir" subdir/new &&
113
- git rm a &&
116
+ git rm A.t &&
114
117
test_tick &&
115
118
git commit -m "again not subdir" &&
116
119
git branch sub &&
@@ -134,7 +137,7 @@ test_expect_success 'more setup' '
134
137
git add subdir/new &&
135
138
test_tick &&
136
139
git commit -m "subdir on master" subdir/new &&
137
- git rm a &&
140
+ git rm A.t &&
138
141
test_tick &&
139
142
git commit -m "again subdir on master" &&
140
143
git merge branch
@@ -283,8 +286,8 @@ test_expect_success 'Tag name filtering allows slashes in tag names' '
283
286
284
287
test_expect_success ' Prune empty commits' '
285
288
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 &&
288
291
git rev-list HEAD > actual &&
289
292
test_cmp expect actual
290
293
'
0 commit comments