t9200: Be careful when checking CVS/Entries
CVS/Entries file can contain a line with single D to say "this directory does not have any subdirectories". Do not get confused with such an entry. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Jul 24, 2007 at 23:25 UTC
c4eaed49c22366f1994a75179adeac47e7863794
1 file changed
+39
-25
t/t9200-git-cvsexportcommit.sh
+39
-25
@@ -28,6 +28,18 @@ git add empty &&
28
git commit -q -a -m "Initial" 2>/dev/null ||
29
exit 1
30
31
+check_entries () {
32
+ # $1 == directory, $2 == expected
33
+ grep '^/' "$1/CVS/Entries" | sort | cut -d/ -f2,3,5 >actual
34
+ if test -z "$2"
35
+ then
36
+ >expected
37
+ else
38
+ printf '%s\n' "$2" | tr '|' '\012' >expected
39
+ fi
40
+ diff -u expected actual
41
+}
42
+
43
test_expect_success \
44
'New file' \
45
'mkdir A B C D E F &&
@@ -43,10 +55,10 @@ test_expect_success \
55
id=$(git rev-list --max-count=1 HEAD) &&
56
(cd "$CVSWORK" &&
57
git cvsexportcommit -c $id &&
46
- test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.1/" &&
47
- test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "newfile2.txt/1.1/" &&
48
- test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "newfile3.png/1.1/-kb" &&
49
- test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "newfile4.png/1.1/-kb" &&
58
+ check_entries A "newfile1.txt/1.1/" &&
59
+ check_entries B "newfile2.txt/1.1/" &&
60
+ check_entries C "newfile3.png/1.1/-kb" &&
61
+ check_entries D "newfile4.png/1.1/-kb" &&
62
diff A/newfile1.txt ../A/newfile1.txt &&
63
diff B/newfile2.txt ../B/newfile2.txt &&
64
diff C/newfile3.png ../C/newfile3.png &&
@@ -67,12 +79,12 @@ test_expect_success \
79
id=$(git rev-list --max-count=1 HEAD) &&
80
(cd "$CVSWORK" &&
81
git cvsexportcommit -c $id &&
70
- test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.2/" &&
71
- test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
72
- test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
73
- test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "newfile4.png/1.2/-kb" &&
74
- test "$(echo $(sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" &&
75
- test "$(echo $(sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" &&
82
+ check_entries A "newfile1.txt/1.2/" &&
83
+ check_entries B "" &&
84
+ check_entries C "" &&
85
+ check_entries D "newfile4.png/1.2/-kb" &&
86
+ check_entries E "newfile5.txt/1.1/" &&
87
+ check_entries F "newfile6.png/1.1/-kb" &&
88
diff A/newfile1.txt ../A/newfile1.txt &&
89
diff D/newfile4.png ../D/newfile4.png &&
90
diff E/newfile5.txt ../E/newfile5.txt &&
@@ -115,12 +127,12 @@ test_expect_success \
127
id=$(git rev-list --max-count=1 HEAD) &&
128
(cd "$CVSWORK" &&
129
git cvsexportcommit -c $id &&
118
- test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.2/" &&
119
- test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
120
- test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
121
- test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
122
- test "$(echo $(sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" &&
123
- test "$(echo $(sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" &&
130
+ check_entries A "newfile1.txt/1.2/" &&
131
+ check_entries B "" &&
132
+ check_entries C "" &&
133
+ check_entries D "" &&
134
+ check_entries E "newfile5.txt/1.1/" &&
135
+ check_entries F "newfile6.png/1.1/-kb" &&
136
diff A/newfile1.txt ../A/newfile1.txt &&
137
diff E/newfile5.txt ../E/newfile5.txt &&
138
diff F/newfile6.png ../F/newfile6.png
@@ -133,12 +145,12 @@ test_expect_success \
145
id=$(git rev-list --max-count=1 HEAD) &&
146
(cd "$CVSWORK" &&
147
git cvsexportcommit -c $id &&
136
- test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
137
- test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
138
- test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
139
- test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
140
- test "$(echo $(sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" &&
141
- test "$(echo $(sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" &&
148
+ check_entries A "" &&
149
+ check_entries B "" &&
150
+ check_entries C "" &&
151
+ check_entries D "" &&
152
+ check_entries E "newfile5.txt/1.1/" &&
153
+ check_entries F "newfile6.png/1.1/-kb" &&
154
diff E/newfile5.txt ../E/newfile5.txt &&
155
diff F/newfile6.png ../F/newfile6.png
156
)'
@@ -154,7 +166,7 @@ test_expect_success \
166
id=$(git rev-list --max-count=1 HEAD) &&
167
(cd "$CVSWORK" &&
168
git-cvsexportcommit -c $id &&
157
- test "$(echo $(sort "G g/CVS/Entries"|cut -d/ -f2,3,5))" = "with spaces.png/1.1/-kb with spaces.txt/1.1/"
169
+ check_entries "G g" "with spaces.png/1.1/-kb|with spaces.txt/1.1/"
170
)'
171
172
test_expect_success \
@@ -166,7 +178,7 @@ test_expect_success \
178
id=$(git rev-list --max-count=1 HEAD) &&
179
(cd "$CVSWORK" &&
180
git-cvsexportcommit -c $id
169
- test "$(echo $(sort "G g/CVS/Entries"|cut -d/ -f2,3,5))" = "with spaces.png/1.2/-kb with spaces.txt/1.2/"
181
+ check_entries "G g" "with spaces.png/1.2/-kb|with spaces.txt/1.2/"
182
)'
183
184
# Some filesystems mangle pathnames with UTF-8 characters --
@@ -191,7 +203,9 @@ test_expect_success \
203
id=$(git rev-list --max-count=1 HEAD) &&
204
(cd "$CVSWORK" &&
205
git-cvsexportcommit -v -c $id &&
194
- test "$(echo $(sort Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/CVS/Entries|cut -d/ -f2,3,5))" = "gårdetsågårdet.png/1.1/-kb gårdetsågårdet.txt/1.1/"
206
+ check_entries \
207
+ "Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö" \
208
+ "gårdetsågårdet.png/1.1/-kb|gårdetsågårdet.txt/1.1/"
209
)'
210
211
fi