3 # Copyright (c) Robin Rosenberg
5 test_description='CVS export comit. '
12 test_expect_success 'skipping git-cvsexportcommit tests, cvs not found' :
17 export CVSROOT=$(pwd)/cvsroot
18 export CVSWORK=$(pwd)/cvswork
19 rm -rf "$CVSROOT" "$CVSWORK"
22 cvs -Q co -d "$CVSWORK" . &&
23 export GIT_DIR=$(pwd)/.git &&
26 git commit -a -m "Initial" 2>/dev/null ||
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) &&
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
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) &&
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
80 # Should fail (but only on the git-cvsexportcommit stage)
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) &&
89 ! git cvsexportcommit -c $id
92 # Should fail, but only on the git-cvsexportcommit stage
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) &&
102 ! git cvsexportcommit -c $id
105 # We reuse the state from two tests back here
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) &&
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
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) &&
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
145 test_expect_success 'Retain execute bit' '
147 echo executeon >G/on &&
149 echo executeoff >G/off &&
152 git commit -a -m "Execute test" &&
155 git-cvsexportcommit -c HEAD