]>
Commit | Line | Data |
---|---|---|
fe142b3a RR |
1 | #!/bin/bash |
2 | # | |
3 | # Copyright (c) Robin Rosenberg | |
4 | # | |
5 | test_description='CVS export comit. ' | |
6 | ||
7 | . ./test-lib.sh | |
8 | ||
9 | cvs >/dev/null 2>&1 | |
10 | if test $? -ne 1 | |
11 | then | |
12 | test_expect_success 'skipping git-cvsexportcommit tests, cvs not found' : | |
13 | test_done | |
14 | exit | |
15 | fi | |
16 | ||
17 | export CVSROOT=$(pwd)/cvsroot | |
18 | export CVSWORK=$(pwd)/cvswork | |
19 | rm -rf "$CVSROOT" "$CVSWORK" | |
20 | mkdir "$CVSROOT" && | |
21 | cvs init && | |
22 | cvs -Q co -d "$CVSWORK" . && | |
23 | export GIT_DIR=$(pwd)/.git && | |
24 | echo >empty && | |
25 | git add empty && | |
26 | git commit -a -m "Initial" 2>/dev/null || | |
27 | exit 1 | |
28 | ||
29 | test_expect_success \ | |
30 | 'New file' \ | |
31 | 'mkdir A B C D E F && | |
32 | echo hello1 >A/newfile1.txt && | |
33 | echo hello2 >B/newfile2.txt && | |
34 | cp ../test9200a.png C/newfile3.png && | |
35 | cp ../test9200a.png D/newfile4.png && | |
36 | git add A/newfile1.txt && | |
37 | git add B/newfile2.txt && | |
38 | git add C/newfile3.png && | |
39 | git add D/newfile4.png && | |
40 | git commit -a -m "Test: New file" && | |
41 | id=$(git rev-list --max-count=1 HEAD) && | |
42 | (cd "$CVSWORK" && | |
43 | git cvsexportcommit -c $id && | |
44 | test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.1/" && | |
45 | test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "newfile2.txt/1.1/" && | |
46 | test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "newfile3.png/1.1/-kb" && | |
47 | test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "newfile4.png/1.1/-kb" && | |
48 | diff A/newfile1.txt ../A/newfile1.txt && | |
49 | diff B/newfile2.txt ../B/newfile2.txt && | |
50 | diff C/newfile3.png ../C/newfile3.png && | |
51 | diff D/newfile4.png ../D/newfile4.png | |
52 | )' | |
53 | ||
54 | test_expect_success \ | |
55 | 'Remove two files, add two and update two' \ | |
56 | 'echo Hello1 >>A/newfile1.txt && | |
57 | rm -f B/newfile2.txt && | |
58 | rm -f C/newfile3.png && | |
59 | echo Hello5 >E/newfile5.txt && | |
60 | cp ../test9200b.png D/newfile4.png && | |
61 | cp ../test9200a.png F/newfile6.png && | |
62 | git add E/newfile5.txt && | |
63 | git add F/newfile6.png && | |
64 | git commit -a -m "Test: Remove, add and update" && | |
65 | id=$(git rev-list --max-count=1 HEAD) && | |
66 | (cd "$CVSWORK" && | |
67 | git cvsexportcommit -c $id && | |
68 | test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.2/" && | |
69 | test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" && | |
70 | test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" && | |
71 | test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "newfile4.png/1.2/-kb" && | |
72 | test "$(echo $(sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" && | |
73 | test "$(echo $(sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" && | |
74 | diff A/newfile1.txt ../A/newfile1.txt && | |
75 | diff D/newfile4.png ../D/newfile4.png && | |
76 | diff E/newfile5.txt ../E/newfile5.txt && | |
77 | diff F/newfile6.png ../F/newfile6.png | |
78 | )' | |
79 | ||
80 | # Should fail (but only on the git-cvsexportcommit stage) | |
81 | test_expect_success \ | |
82 | 'Fail to change binary more than one generation old' \ | |
83 | 'cat F/newfile6.png >>D/newfile4.png && | |
84 | git commit -a -m "generatiion 1" && | |
85 | cat F/newfile6.png >>D/newfile4.png && | |
86 | git commit -a -m "generation 2" && | |
87 | id=$(git rev-list --max-count=1 HEAD) && | |
88 | (cd "$CVSWORK" && | |
89 | ! git cvsexportcommit -c $id | |
90 | )' | |
91 | ||
92 | # Should fail, but only on the git-cvsexportcommit stage | |
93 | test_expect_success \ | |
94 | 'Fail to remove binary file more than one generation old' \ | |
95 | 'git reset --hard HEAD^ && | |
96 | cat F/newfile6.png >>D/newfile4.png && | |
97 | git commit -a -m "generation 2 (again)" && | |
98 | rm -f D/newfile4.png && | |
99 | git commit -a -m "generation 3" && | |
100 | id=$(git rev-list --max-count=1 HEAD) && | |
101 | (cd "$CVSWORK" && | |
102 | ! git cvsexportcommit -c $id | |
103 | )' | |
104 | ||
105 | # We reuse the state from two tests back here | |
106 | ||
107 | # This test is here because a patch for only binary files will | |
108 | # fail with gnu patch, so cvsexportcommit must handle that. | |
109 | test_expect_success \ | |
110 | 'Remove only binary files' \ | |
111 | 'git reset --hard HEAD^^^ && | |
112 | rm -f D/newfile4.png && | |
113 | git commit -a -m "test: remove only a binary file" && | |
114 | id=$(git rev-list --max-count=1 HEAD) && | |
115 | (cd "$CVSWORK" && | |
116 | git cvsexportcommit -c $id && | |
117 | test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.2/" && | |
118 | test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" && | |
119 | test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" && | |
120 | test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "" && | |
121 | test "$(echo $(sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" && | |
122 | test "$(echo $(sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" && | |
123 | diff A/newfile1.txt ../A/newfile1.txt && | |
124 | diff E/newfile5.txt ../E/newfile5.txt && | |
125 | diff F/newfile6.png ../F/newfile6.png | |
126 | )' | |
127 | ||
128 | test_expect_success \ | |
129 | 'Remove only a text file' \ | |
130 | 'rm -f A/newfile1.txt && | |
131 | git commit -a -m "test: remove only a binary file" && | |
132 | id=$(git rev-list --max-count=1 HEAD) && | |
133 | (cd "$CVSWORK" && | |
134 | git cvsexportcommit -c $id && | |
135 | test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "" && | |
136 | test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" && | |
137 | test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" && | |
138 | test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "" && | |
139 | test "$(echo $(sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" && | |
140 | test "$(echo $(sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" && | |
141 | diff E/newfile5.txt ../E/newfile5.txt && | |
142 | diff F/newfile6.png ../F/newfile6.png | |
143 | )' | |
144 | ||
7c0f7028 JM |
145 | test_expect_success 'Retain execute bit' ' |
146 | mkdir G && | |
147 | echo executeon >G/on && | |
148 | chmod +x G/on && | |
149 | echo executeoff >G/off && | |
150 | git add G/on && | |
151 | git add G/off && | |
152 | git commit -a -m "Execute test" && | |
153 | ( | |
154 | cd "$CVSWORK" && | |
155 | git-cvsexportcommit -c HEAD | |
156 | test -x G/on && | |
157 | ! test -x G/off | |
158 | ) | |
159 | ' | |
160 | ||
fe142b3a | 161 | test_done |