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