~ubuntu-branches/debian/sid/git/sid

« back to all changes in this revision

Viewing changes to t/t9810-git-p4-rcs.sh

  • Committer: Package Import Robot
  • Author(s): Jonathan Nieder
  • Date: 2013-06-12 07:50:53 UTC
  • mfrom: (1.2.19) (2.1.31 experimental)
  • Revision ID: package-import@ubuntu.com-20130612075053-uue9xe0dq0rvm44y
Tags: 1:1.8.3.1-1
* merge branch debian-experimental
* new upstream point release (see RelNotes/1.8.3.1.txt).
* debian/watch: use xz-compressed tarballs from kernel.org.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/sh
2
2
 
3
 
test_description='git-p4 rcs keywords'
 
3
test_description='git p4 rcs keywords'
4
4
 
5
5
. ./lib-git-p4.sh
6
6
 
26
26
                line7
27
27
                line8
28
28
                EOF
29
 
                cp filek fileko &&
30
 
                sed -i "s/Revision/Revision: do not scrub me/" fileko
31
 
                cp fileko file_text &&
32
 
                sed -i "s/Id/Id: do not scrub me/" file_text
 
29
                sed "s/Revision/Revision: do not scrub me/" <filek >fileko &&
 
30
                sed "s/Id/Id: do not scrub me/" <fileko >file_text &&
33
31
                p4 add -t text+k filek &&
34
32
                p4 submit -d "filek" &&
35
33
                p4 add -t text+ko fileko &&
84
82
#
85
83
test_expect_success 'edit far away from RCS lines' '
86
84
        test_when_finished cleanup_git &&
87
 
        "$GITP4" clone --dest="$git" //depot &&
 
85
        git p4 clone --dest="$git" //depot &&
88
86
        (
89
87
                cd "$git" &&
90
88
                git config git-p4.skipSubmitEdit true &&
91
 
                sed -i "s/^line7/line7 edit/" filek &&
 
89
                sed "s/^line7/line7 edit/" <filek >filek.tmp &&
 
90
                mv -f filek.tmp filek &&
92
91
                git commit -m "filek line7 edit" filek &&
93
 
                "$GITP4" submit &&
 
92
                git p4 submit &&
94
93
                scrub_k_check filek
95
94
        )
96
95
'
100
99
#
101
100
test_expect_success 'edit near RCS lines' '
102
101
        test_when_finished cleanup_git &&
103
 
        "$GITP4" clone --dest="$git" //depot &&
 
102
        git p4 clone --dest="$git" //depot &&
104
103
        (
105
104
                cd "$git" &&
106
105
                git config git-p4.skipSubmitEdit true &&
107
106
                git config git-p4.attemptRCSCleanup true &&
108
 
                sed -i "s/^line4/line4 edit/" filek &&
 
107
                sed "s/^line4/line4 edit/" <filek >filek.tmp &&
 
108
                mv -f filek.tmp filek &&
109
109
                git commit -m "filek line4 edit" filek &&
110
 
                "$GITP4" submit &&
 
110
                git p4 submit &&
111
111
                scrub_k_check filek
112
112
        )
113
113
'
117
117
#
118
118
test_expect_success 'edit keyword lines' '
119
119
        test_when_finished cleanup_git &&
120
 
        "$GITP4" clone --dest="$git" //depot &&
 
120
        git p4 clone --dest="$git" //depot &&
121
121
        (
122
122
                cd "$git" &&
123
123
                git config git-p4.skipSubmitEdit true &&
124
124
                git config git-p4.attemptRCSCleanup true &&
125
 
                sed -i "/Revision/d" filek &&
 
125
                sed "/Revision/d" <filek >filek.tmp &&
 
126
                mv -f filek.tmp filek &&
126
127
                git commit -m "filek remove Revision line" filek &&
127
 
                "$GITP4" submit &&
 
128
                git p4 submit &&
128
129
                scrub_k_check filek
129
130
        )
130
131
'
134
135
#
135
136
test_expect_success 'scrub ko files differently' '
136
137
        test_when_finished cleanup_git &&
137
 
        "$GITP4" clone --dest="$git" //depot &&
 
138
        git p4 clone --dest="$git" //depot &&
138
139
        (
139
140
                cd "$git" &&
140
141
                git config git-p4.skipSubmitEdit true &&
141
142
                git config git-p4.attemptRCSCleanup true &&
142
 
                sed -i "s/^line4/line4 edit/" fileko &&
 
143
                sed "s/^line4/line4 edit/" <fileko >fileko.tmp &&
 
144
                mv -f fileko.tmp fileko &&
143
145
                git commit -m "fileko line4 edit" fileko &&
144
 
                "$GITP4" submit &&
 
146
                git p4 submit &&
145
147
                scrub_ko_check fileko &&
146
148
                ! scrub_k_check fileko
147
149
        )
148
150
'
149
151
 
150
 
# hack; git-p4 submit should do it on its own
 
152
# hack; git p4 submit should do it on its own
151
153
test_expect_success 'cleanup after failure' '
152
154
        (
153
155
                cd "$cli" &&
155
157
        )
156
158
'
157
159
 
 
160
# perl $File:: bug check
 
161
test_expect_success 'ktext expansion should not expand multi-line $File::' '
 
162
        (
 
163
                cd "$cli" &&
 
164
                cat >lv.pm <<-\EOF
 
165
                my $wanted = sub { my $f = $File::Find::name;
 
166
                                    if ( -f && $f =~ /foo/ ) {
 
167
                EOF
 
168
                p4 add -t ktext lv.pm &&
 
169
                p4 submit -d "lv.pm"
 
170
        ) &&
 
171
        test_when_finished cleanup_git &&
 
172
        git p4 clone --dest="$git" //depot &&
 
173
        (
 
174
                cd "$git" &&
 
175
                test_cmp "$cli/lv.pm" lv.pm
 
176
        )
 
177
'
 
178
 
158
179
#
159
180
# Do not scrub anything but +k or +ko files.  Sneak a change into
160
181
# the cli file so that submit will get a conflict.  Make sure that
161
182
# scrubbing doesn't make a mess of things.
162
183
#
163
 
# Assumes that git-p4 exits leaving the p4 file open, with the
164
 
# conflict-generating patch unapplied.
165
 
#
166
184
# This might happen only if the git repo is behind the p4 repo at
167
185
# submit time, and there is a conflict.
168
186
#
169
187
test_expect_success 'do not scrub plain text' '
170
188
        test_when_finished cleanup_git &&
171
 
        "$GITP4" clone --dest="$git" //depot &&
 
189
        git p4 clone --dest="$git" //depot &&
172
190
        (
173
191
                cd "$git" &&
174
192
                git config git-p4.skipSubmitEdit true &&
175
193
                git config git-p4.attemptRCSCleanup true &&
176
 
                sed -i "s/^line4/line4 edit/" file_text &&
 
194
                sed "s/^line4/line4 edit/" <file_text >file_text.tmp &&
 
195
                mv -f file_text.tmp file_text &&
177
196
                git commit -m "file_text line4 edit" file_text &&
178
197
                (
179
198
                        cd "$cli" &&
180
199
                        p4 open file_text &&
181
 
                        sed -i "s/^line5/line5 p4 edit/" file_text &&
 
200
                        sed "s/^line5/line5 p4 edit/" <file_text >file_text.tmp &&
 
201
                        mv -f file_text.tmp file_text &&
182
202
                        p4 submit -d "file5 p4 edit"
183
203
                ) &&
184
 
                ! "$GITP4" submit &&
 
204
                echo s | test_expect_code 1 git p4 submit &&
185
205
                (
186
 
                        # exepct something like:
187
 
                        #    file_text - file(s) not opened on this client
188
 
                        # but not copious diff output
 
206
                        # make sure the file is not left open
189
207
                        cd "$cli" &&
190
 
                        p4 diff file_text >wc &&
191
 
                        test_line_count = 1 wc
 
208
                        ! p4 fstat -T action file_text
192
209
                )
193
210
        )
194
211
'
195
212
 
196
 
# hack; git-p4 submit should do it on its own
 
213
# hack; git p4 submit should do it on its own
197
214
test_expect_success 'cleanup after failure 2' '
198
215
        (
199
216
                cd "$cli" &&
239
256
# even though the change itself would otherwise apply cleanly.
240
257
test_expect_success 'cope with rcs keyword expansion damage' '
241
258
        test_when_finished cleanup_git &&
242
 
        "$GITP4" clone --dest="$git" //depot &&
 
259
        git p4 clone --dest="$git" //depot &&
243
260
        (
244
261
                cd "$git" &&
245
262
                git config git-p4.skipSubmitEdit true &&
246
263
                git config git-p4.attemptRCSCleanup true &&
247
 
                (cd ../cli && p4_append_to_file kwfile1.c) &&
 
264
                (cd "$cli" && p4_append_to_file kwfile1.c) &&
248
265
                old_lines=$(wc -l <kwfile1.c) &&
249
 
                perl -n -i -e "print unless m/Revision:/" kwfile1.c &&
 
266
                "$PERL_PATH" -n -i -e "print unless m/Revision:/" kwfile1.c &&
250
267
                new_lines=$(wc -l <kwfile1.c) &&
251
268
                test $new_lines = $(($old_lines - 1)) &&
252
269
 
253
270
                git add kwfile1.c &&
254
271
                git commit -m "Zap an RCS kw line" &&
255
 
                "$GITP4" submit &&
256
 
                "$GITP4" rebase &&
 
272
                git p4 submit &&
 
273
                git p4 rebase &&
257
274
                git diff p4/master &&
258
 
                "$GITP4" commit &&
 
275
                git p4 commit &&
259
276
                echo "try modifying in both" &&
260
277
                cd "$cli" &&
261
278
                p4 edit kwfile1.c &&
265
282
                echo "line from git at the top" | cat - kwfile1.c >kwfile1.c.new &&
266
283
                mv kwfile1.c.new kwfile1.c &&
267
284
                git commit -m "Add line in git at the top" kwfile1.c &&
268
 
                "$GITP4" rebase &&
269
 
                "$GITP4" submit
 
285
                git p4 rebase &&
 
286
                git p4 submit
270
287
        )
271
288
'
272
289
 
280
297
                cat kwdelfile.c &&
281
298
                grep 1 kwdelfile.c
282
299
        ) &&
283
 
        "$GITP4" clone --dest="$git" //depot &&
 
300
        git p4 clone --dest="$git" //depot &&
284
301
        (
285
302
                cd "$git" &&
286
303
                grep Revision kwdelfile.c &&
288
305
                git commit -m "Delete a file containing RCS keywords" &&
289
306
                git config git-p4.skipSubmitEdit true &&
290
307
                git config git-p4.attemptRCSCleanup true &&
291
 
                "$GITP4" submit
 
308
                git p4 submit
292
309
        ) &&
293
310
        (
294
311
                cd "$cli" &&
301
318
# work fine without any special handling.
302
319
test_expect_success 'Add keywords in git which match the default p4 values' '
303
320
        test_when_finished cleanup_git &&
304
 
        "$GITP4" clone --dest="$git" //depot &&
 
321
        git p4 clone --dest="$git" //depot &&
305
322
        (
306
323
                cd "$git" &&
307
324
                echo "NewKW: \$Revision\$" >>kwfile1.c &&
309
326
                git commit -m "Adding RCS keywords in git" &&
310
327
                git config git-p4.skipSubmitEdit true &&
311
328
                git config git-p4.attemptRCSCleanup true &&
312
 
                "$GITP4" submit
 
329
                git p4 submit
313
330
        ) &&
314
331
        (
315
332
                cd "$cli" &&
325
342
#
326
343
test_expect_failure 'Add keywords in git which do not match the default p4 values' '
327
344
        test_when_finished cleanup_git &&
328
 
        "$GITP4" clone --dest="$git" //depot &&
 
345
        git p4 clone --dest="$git" //depot &&
329
346
        (
330
347
                cd "$git" &&
331
348
                echo "NewKW2: \$Revision:1\$" >>kwfile1.c &&
333
350
                git commit -m "Adding RCS keywords in git" &&
334
351
                git config git-p4.skipSubmitEdit true &&
335
352
                git config git-p4.attemptRCSCleanup true &&
336
 
                "$GITP4" submit
 
353
                git p4 submit
337
354
        ) &&
338
355
        (
339
356
                cd "$cli" &&
343
360
        )
344
361
'
345
362
 
346
 
# Check that the existing merge conflict handling still works.
347
 
# Modify kwfile1.c in git, and delete in p4. We should be able
348
 
# to skip the git commit.
349
 
#
350
 
test_expect_success 'merge conflict handling still works' '
351
 
        test_when_finished cleanup_git &&
352
 
        (
353
 
                cd "$cli" &&
354
 
                echo "Hello:\$Id\$" >merge2.c &&
355
 
                echo "World" >>merge2.c &&
356
 
                p4 add -t ktext merge2.c &&
357
 
                p4 submit -d "add merge test file"
358
 
        ) &&
359
 
        "$GITP4" clone --dest="$git" //depot &&
360
 
        (
361
 
                cd "$git" &&
362
 
                sed -e "/Hello/d" merge2.c >merge2.c.tmp &&
363
 
                mv merge2.c.tmp merge2.c &&
364
 
                git add merge2.c &&
365
 
                git commit -m "Modifying merge2.c"
366
 
        ) &&
367
 
        (
368
 
                cd "$cli" &&
369
 
                p4 delete merge2.c &&
370
 
                p4 submit -d "remove merge test file"
371
 
        ) &&
372
 
        (
373
 
                cd "$git" &&
374
 
                test -f merge2.c &&
375
 
                git config git-p4.skipSubmitEdit true &&
376
 
                git config git-p4.attemptRCSCleanup true &&
377
 
                !(echo "s" | "$GITP4" submit) &&
378
 
                git rebase --skip &&
379
 
                ! test -f merge2.c
380
 
        )
381
 
'
382
 
 
383
 
 
384
363
test_expect_success 'kill p4d' '
385
364
        kill_p4d
386
365
'