]> git.ipfire.org Git - thirdparty/git.git/blame - contrib/git-svn/t/t0000-contrib-git-svn.sh
GIT 1.4.0
[thirdparty/git.git] / contrib / git-svn / t / t0000-contrib-git-svn.sh
CommitLineData
96a40b27
EW
1#!/bin/sh
2#
3# Copyright (c) 2006 Eric Wong
4#
5
96a40b27 6test_description='git-svn tests'
36f5b1f0 7. ./lib-git-svn.sh
96a40b27
EW
8
9mkdir import
96a40b27
EW
10cd import
11
12echo foo > foo
13ln -s foo foo.link
14mkdir -p dir/a/b/c/d/e
15echo 'deep dir' > dir/a/b/c/d/e/file
16mkdir -p bar
17echo 'zzz' > bar/zzz
18echo '#!/bin/sh' > exec.sh
19chmod +x exec.sh
36f5b1f0 20svn import -m 'import for git-svn' . "$svnrepo" >/dev/null
96a40b27
EW
21
22cd ..
96a40b27
EW
23rm -rf import
24
25test_expect_success \
26 'initialize git-svn' \
27 "git-svn init $svnrepo"
28
29test_expect_success \
30 'import an SVN revision into git' \
31 'git-svn fetch'
32
33
34name='try a deep --rmdir with a commit'
2beb3cdd 35git checkout -b mybranch remotes/git-svn
96a40b27
EW
36mv dir/a/b/c/d/e/file dir/file
37cp dir/file file
38git update-index --add --remove dir/a/b/c/d/e/file dir/file file
39git commit -m "$name"
40
41test_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
46name='detect node change from file to directory #1'
47mkdir dir/new_file
48mv dir/file dir/new_file/file
49mv dir/new_file dir/file
50git update-index --remove dir/file
51git update-index --add dir/file/file
52git commit -m "$name"
53
54test_expect_code 1 "$name" \
2beb3cdd 55 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch' \
96a40b27
EW
56 || true
57
58
59name='detect node change from directory to file #1'
60rm -rf dir $GIT_DIR/index
2beb3cdd 61git checkout -b mybranch2 remotes/git-svn
96a40b27
EW
62mv bar/zzz zzz
63rm -rf bar
64mv zzz bar
65git update-index --remove -- bar/zzz
66git update-index --add -- bar
67git commit -m "$name"
68
69test_expect_code 1 "$name" \
2beb3cdd 70 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch2' \
96a40b27
EW
71 || true
72
73
74name='detect node change from file to directory #2'
75rm -f $GIT_DIR/index
2beb3cdd 76git checkout -b mybranch3 remotes/git-svn
96a40b27
EW
77rm bar/zzz
78git-update-index --remove bar/zzz
79mkdir bar/zzz
80echo yyy > bar/zzz/yyy
81git-update-index --add bar/zzz/yyy
82git commit -m "$name"
83
84test_expect_code 1 "$name" \
2beb3cdd 85 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch3' \
96a40b27
EW
86 || true
87
88
89name='detect node change from directory to file #2'
90rm -f $GIT_DIR/index
2beb3cdd 91git checkout -b mybranch4 remotes/git-svn
96a40b27
EW
92rm -rf dir
93git update-index --remove -- dir/file
94touch dir
95echo asdf > dir
96git update-index --add -- dir
97git commit -m "$name"
98
99test_expect_code 1 "$name" \
2beb3cdd 100 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch4' \
96a40b27
EW
101 || true
102
103
104name='remove executable bit from a file'
105rm -f $GIT_DIR/index
2beb3cdd 106git checkout -b mybranch5 remotes/git-svn
96a40b27
EW
107chmod -x exec.sh
108git update-index exec.sh
109git commit -m "$name"
110
111test_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
116name='add executable bit back file'
117chmod +x exec.sh
118git update-index exec.sh
119git commit -m "$name"
120
121test_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
127name='executable file becomes a symlink to bar/zzz (file)'
128rm exec.sh
129ln -s bar/zzz exec.sh
130git update-index exec.sh
131git commit -m "$name"
132
133test_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
139name='new symlink is added to a file that was also just made executable'
140chmod +x bar/zzz
141ln -s bar/zzz exec-2.sh
142git update-index --add bar/zzz exec-2.sh
143git commit -m "$name"
144
145test_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
152name='modify a symlink to become a file'
153git help > help || true
154rm exec-2.sh
155cp help exec-2.sh
156git update-index exec-2.sh
157git commit -m "$name"
158
159test_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
167name='test fetch functionality (svn => git) with alternate GIT_SVN_ID'
168GIT_SVN_ID=alt
169export GIT_SVN_ID
170test_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
176test_done
177