t9801: do not overuse test_must_fail
[git] / t / t9146-git-svn-empty-dirs.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2009 Eric Wong
4
5 test_description='git svn creates empty directories'
6 . ./lib-git-svn.sh
7
8 test_expect_success 'initialize repo' '
9         for i in a b c d d/e d/e/f "weird file name"
10         do
11                 svn_cmd mkdir -m "mkdir $i" "$svnrepo"/"$i"
12         done
13 '
14
15 test_expect_success 'clone' 'git svn clone "$svnrepo" cloned'
16
17 test_expect_success 'empty directories exist' '
18         (
19                 cd cloned &&
20                 for i in a b c d d/e d/e/f "weird file name"
21                 do
22                         if ! test -d "$i"
23                         then
24                                 echo >&2 "$i does not exist"
25                                 exit 1
26                         fi
27                 done
28         )
29 '
30
31 test_expect_success 'option automkdirs set to false' '
32         (
33                 git svn init "$svnrepo" cloned-no-mkdirs &&
34                 cd cloned-no-mkdirs &&
35                 git config svn-remote.svn.automkdirs false &&
36                 git svn fetch &&
37                 for i in a b c d d/e d/e/f "weird file name"
38                 do
39                         if test -d "$i"
40                         then
41                                 echo >&2 "$i exists"
42                                 exit 1
43                         fi
44                 done
45         )
46 '
47
48 test_expect_success 'more emptiness' '
49         svn_cmd mkdir -m "bang bang"  "$svnrepo"/"! !"
50 '
51
52 test_expect_success 'git svn rebase creates empty directory' '
53         ( cd cloned && git svn rebase ) &&
54         test -d cloned/"! !"
55 '
56
57 test_expect_success 'git svn mkdirs recreates empty directories' '
58         (
59                 cd cloned &&
60                 rm -r * &&
61                 git svn mkdirs &&
62                 for i in a b c d d/e d/e/f "weird file name" "! !"
63                 do
64                         if ! test -d "$i"
65                         then
66                                 echo >&2 "$i does not exist"
67                                 exit 1
68                         fi
69                 done
70         )
71 '
72
73 test_expect_success 'git svn mkdirs -r works' '
74         (
75                 cd cloned &&
76                 rm -r * &&
77                 git svn mkdirs -r7 &&
78                 for i in a b c d d/e d/e/f "weird file name"
79                 do
80                         if ! test -d "$i"
81                         then
82                                 echo >&2 "$i does not exist"
83                                 exit 1
84                         fi
85                 done
86
87                 if test -d "! !"
88                 then
89                         echo >&2 "$i should not exist"
90                         exit 1
91                 fi
92
93                 git svn mkdirs -r8 &&
94                 if ! test -d "! !"
95                 then
96                         echo >&2 "$i not exist"
97                         exit 1
98                 fi
99         )
100 '
101
102 test_expect_success 'initialize trunk' '
103         for i in trunk trunk/a trunk/"weird file name"
104         do
105                 svn_cmd mkdir -m "mkdir $i" "$svnrepo"/"$i"
106         done
107 '
108
109 test_expect_success 'clone trunk' 'git svn clone -s "$svnrepo" trunk'
110
111 test_expect_success 'empty directories in trunk exist' '
112         (
113                 cd trunk &&
114                 for i in a "weird file name"
115                 do
116                         if ! test -d "$i"
117                         then
118                                 echo >&2 "$i does not exist"
119                                 exit 1
120                         fi
121                 done
122         )
123 '
124
125 test_expect_success 'remove a top-level directory from svn' '
126         svn_cmd rm -m "remove d" "$svnrepo"/d
127 '
128
129 test_expect_success 'removed top-level directory does not exist' '
130         git svn clone "$svnrepo" removed &&
131         test ! -e removed/d
132
133 '
134 unhandled=.git/svn/refs/remotes/git-svn/unhandled.log
135 test_expect_success 'git svn gc-ed files work' '
136         (
137                 cd removed &&
138                 git svn gc &&
139                 : Compress::Zlib may not be available &&
140                 if test -f "$unhandled".gz
141                 then
142                         svn_cmd mkdir -m gz "$svnrepo"/gz &&
143                         git reset --hard $(git rev-list HEAD | tail -1) &&
144                         git svn rebase &&
145                         test -f "$unhandled".gz &&
146                         test -f "$unhandled" &&
147                         for i in a b c "weird file name" gz "! !"
148                         do
149                                 if ! test -d "$i"
150                                 then
151                                         echo >&2 "$i does not exist"
152                                         exit 1
153                                 fi
154                         done
155                 fi
156         )
157 '
158
159 test_done