@matheusbsbs / matheus-bagliano / commits / 77f2e4f5f3
Fork 0

t7003: Use test_commit instead of custom function

t7003-filter-branch.sh had a make_commit() function that was identical to test_commit() in test-lib.sh except that it used tr to create a lowercase file name from the uppercase branch name instead of appending ".t". Not only is this unneeded code duplication, it also was something simply waiting to fail on case-insensitive file systems. So replace all uses of make_commit with test_commit. While we're editing the setup, chain it together with && so that failures early in the sequence don't get lost and add a commit graph. Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brian Gernhardt committed Sep 10, 2010 at 18:06 UTC 77f2e4f5f3e448794fd4fa80e898e4388042fabb
1 file changed +41 -38
t/t7003-filter-branch.sh
+41 -38
@@ -3,31 +3,34 @@
3 test_description='git filter-branch'
4 . ./test-lib.sh
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 -
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 +
34
35 H=$(git rev-parse H)
36
@@ -65,14 +68,14 @@ test_expect_success 'Fail if commit filter fails' '
68 '
69
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
72 '
73
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 &&
77 test -f doh &&
75 - test d = "$(cat doh)"
78 + test D = "$(cat doh)"
79 '
80
81 test_expect_success 'rewrite, renaming a specific directory' '
@@ -80,18 +83,18 @@ test_expect_success 'rewrite, renaming a specific directory' '
83 '
84
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 --)" &&
87 ! test -d dir &&
88 test -d diroh &&
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)"
92 '
93
94 git tag oldD HEAD~4
95 test_expect_success 'rewrite one branch, keeping a side branch' '
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
98 '
99
100 test_expect_success 'common ancestor is still common (unchanged)' '
@@ -104,13 +107,13 @@ test_expect_success 'filter subdirectory only' '
107 git add subdir/new &&
108 test_tick &&
109 git commit -m "subdir" &&
107 - echo H > a &&
110 + echo H > A.t &&
111 test_tick &&
109 - git commit -m "not subdir" a &&
112 + git commit -m "not subdir" A.t &&
113 echo A > subdir/new &&
114 test_tick &&
115 git commit -m "again subdir" subdir/new &&
113 - git rm a &&
116 + git rm A.t &&
117 test_tick &&
118 git commit -m "again not subdir" &&
119 git branch sub &&
@@ -134,7 +137,7 @@ test_expect_success 'more setup' '
137 git add subdir/new &&
138 test_tick &&
139 git commit -m "subdir on master" subdir/new &&
137 - git rm a &&
140 + git rm A.t &&
141 test_tick &&
142 git commit -m "again subdir on master" &&
143 git merge branch
@@ -283,8 +286,8 @@ test_expect_success 'Tag name filtering allows slashes in tag names' '
286
287 test_expect_success 'Prune empty commits' '
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 &&
291 git rev-list HEAD > actual &&
292 test_cmp expect actual
293 '