]>
Commit | Line | Data |
---|---|---|
96a40b27 EW |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2006 Eric Wong | |
4 | # | |
5 | ||
96a40b27 | 6 | test_description='git-svn tests' |
36f5b1f0 | 7 | . ./lib-git-svn.sh |
96a40b27 EW |
8 | |
9 | mkdir import | |
96a40b27 EW |
10 | cd import |
11 | ||
12 | echo foo > foo | |
13 | ln -s foo foo.link | |
14 | mkdir -p dir/a/b/c/d/e | |
15 | echo 'deep dir' > dir/a/b/c/d/e/file | |
16 | mkdir -p bar | |
17 | echo 'zzz' > bar/zzz | |
18 | echo '#!/bin/sh' > exec.sh | |
19 | chmod +x exec.sh | |
36f5b1f0 | 20 | svn import -m 'import for git-svn' . "$svnrepo" >/dev/null |
96a40b27 EW |
21 | |
22 | cd .. | |
96a40b27 EW |
23 | rm -rf import |
24 | ||
25 | test_expect_success \ | |
26 | 'initialize git-svn' \ | |
27 | "git-svn init $svnrepo" | |
28 | ||
29 | test_expect_success \ | |
30 | 'import an SVN revision into git' \ | |
31 | 'git-svn fetch' | |
32 | ||
33 | ||
34 | name='try a deep --rmdir with a commit' | |
2beb3cdd | 35 | git checkout -b mybranch remotes/git-svn |
96a40b27 EW |
36 | mv dir/a/b/c/d/e/file dir/file |
37 | cp dir/file file | |
38 | git update-index --add --remove dir/a/b/c/d/e/file dir/file file | |
39 | git commit -m "$name" | |
40 | ||
41 | test_expect_success "$name" \ | |
2beb3cdd | 42 | "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch && |
96a40b27 EW |
43 | test -d $SVN_TREE/dir && test ! -d $SVN_TREE/dir/a" |
44 | ||
45 | ||
46 | name='detect node change from file to directory #1' | |
47 | mkdir dir/new_file | |
48 | mv dir/file dir/new_file/file | |
49 | mv dir/new_file dir/file | |
50 | git update-index --remove dir/file | |
51 | git update-index --add dir/file/file | |
52 | git commit -m "$name" | |
53 | ||
54 | test_expect_code 1 "$name" \ | |
2beb3cdd | 55 | 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch' \ |
96a40b27 EW |
56 | || true |
57 | ||
58 | ||
59 | name='detect node change from directory to file #1' | |
60 | rm -rf dir $GIT_DIR/index | |
2beb3cdd | 61 | git checkout -b mybranch2 remotes/git-svn |
96a40b27 EW |
62 | mv bar/zzz zzz |
63 | rm -rf bar | |
64 | mv zzz bar | |
65 | git update-index --remove -- bar/zzz | |
66 | git update-index --add -- bar | |
67 | git commit -m "$name" | |
68 | ||
69 | test_expect_code 1 "$name" \ | |
2beb3cdd | 70 | 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch2' \ |
96a40b27 EW |
71 | || true |
72 | ||
73 | ||
74 | name='detect node change from file to directory #2' | |
75 | rm -f $GIT_DIR/index | |
2beb3cdd | 76 | git checkout -b mybranch3 remotes/git-svn |
96a40b27 EW |
77 | rm bar/zzz |
78 | git-update-index --remove bar/zzz | |
79 | mkdir bar/zzz | |
80 | echo yyy > bar/zzz/yyy | |
81 | git-update-index --add bar/zzz/yyy | |
82 | git commit -m "$name" | |
83 | ||
84 | test_expect_code 1 "$name" \ | |
2beb3cdd | 85 | 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch3' \ |
96a40b27 EW |
86 | || true |
87 | ||
88 | ||
89 | name='detect node change from directory to file #2' | |
90 | rm -f $GIT_DIR/index | |
2beb3cdd | 91 | git checkout -b mybranch4 remotes/git-svn |
96a40b27 EW |
92 | rm -rf dir |
93 | git update-index --remove -- dir/file | |
94 | touch dir | |
95 | echo asdf > dir | |
96 | git update-index --add -- dir | |
97 | git commit -m "$name" | |
98 | ||
99 | test_expect_code 1 "$name" \ | |
2beb3cdd | 100 | 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch4' \ |
96a40b27 EW |
101 | || true |
102 | ||
103 | ||
104 | name='remove executable bit from a file' | |
105 | rm -f $GIT_DIR/index | |
2beb3cdd | 106 | git checkout -b mybranch5 remotes/git-svn |
96a40b27 EW |
107 | chmod -x exec.sh |
108 | git update-index exec.sh | |
109 | git commit -m "$name" | |
110 | ||
111 | test_expect_success "$name" \ | |
2beb3cdd | 112 | "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 && |
96a40b27 EW |
113 | test ! -x $SVN_TREE/exec.sh" |
114 | ||
115 | ||
116 | name='add executable bit back file' | |
117 | chmod +x exec.sh | |
118 | git update-index exec.sh | |
119 | git commit -m "$name" | |
120 | ||
121 | test_expect_success "$name" \ | |
2beb3cdd | 122 | "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 && |
96a40b27 EW |
123 | test -x $SVN_TREE/exec.sh" |
124 | ||
125 | ||
126 | ||
127 | name='executable file becomes a symlink to bar/zzz (file)' | |
128 | rm exec.sh | |
129 | ln -s bar/zzz exec.sh | |
130 | git update-index exec.sh | |
131 | git commit -m "$name" | |
132 | ||
133 | test_expect_success "$name" \ | |
2beb3cdd | 134 | "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 && |
96a40b27 EW |
135 | test -L $SVN_TREE/exec.sh" |
136 | ||
137 | ||
138 | ||
139 | name='new symlink is added to a file that was also just made executable' | |
140 | chmod +x bar/zzz | |
141 | ln -s bar/zzz exec-2.sh | |
142 | git update-index --add bar/zzz exec-2.sh | |
143 | git commit -m "$name" | |
144 | ||
145 | test_expect_success "$name" \ | |
2beb3cdd | 146 | "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 && |
96a40b27 EW |
147 | test -x $SVN_TREE/bar/zzz && |
148 | test -L $SVN_TREE/exec-2.sh" | |
149 | ||
150 | ||
151 | ||
152 | name='modify a symlink to become a file' | |
153 | git help > help || true | |
154 | rm exec-2.sh | |
155 | cp help exec-2.sh | |
156 | git update-index exec-2.sh | |
157 | git commit -m "$name" | |
158 | ||
159 | test_expect_success "$name" \ | |
2beb3cdd | 160 | "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 && |
96a40b27 EW |
161 | test -f $SVN_TREE/exec-2.sh && |
162 | test ! -L $SVN_TREE/exec-2.sh && | |
163 | diff -u help $SVN_TREE/exec-2.sh" | |
164 | ||
165 | ||
166 | ||
167 | name='test fetch functionality (svn => git) with alternate GIT_SVN_ID' | |
168 | GIT_SVN_ID=alt | |
169 | export GIT_SVN_ID | |
170 | test_expect_success "$name" \ | |
2beb3cdd EW |
171 | "git-svn init $svnrepo && git-svn fetch && |
172 | git-rev-list --pretty=raw remotes/git-svn | grep ^tree | uniq > a && | |
173 | git-rev-list --pretty=raw remotes/alt | grep ^tree | uniq > b && | |
96a40b27 EW |
174 | diff -u a b" |
175 | ||
176 | test_done | |
177 |