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 &&
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 &&
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 &&
94
93
scrub_k_check filek
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 &&
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 &&
111
111
scrub_k_check filek
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 &&
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 &&
128
129
scrub_k_check filek
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 &&
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 &&
145
147
scrub_ko_check fileko &&
146
148
! scrub_k_check fileko
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' '
160
# perl $File:: bug check
161
test_expect_success 'ktext expansion should not expand multi-line $File::' '
165
my $wanted = sub { my $f = $File::Find::name;
166
if ( -f && $f =~ /foo/ ) {
168
p4 add -t ktext lv.pm &&
171
test_when_finished cleanup_git &&
172
git p4 clone --dest="$git" //depot &&
175
test_cmp "$cli/lv.pm" lv.pm
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.
163
# Assumes that git-p4 exits leaving the p4 file open, with the
164
# conflict-generating patch unapplied.
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.
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 &&
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 &&
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"
204
echo s | test_expect_code 1 git p4 submit &&
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
190
p4 diff file_text >wc &&
191
test_line_count = 1 wc
208
! p4 fstat -T action file_text
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' '
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 &&
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)) &&
253
270
git add kwfile1.c &&
254
271
git commit -m "Zap an RCS kw line" &&
257
274
git diff p4/master &&
259
276
echo "try modifying in both" &&
261
278
p4 edit kwfile1.c &&
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 &&
307
324
echo "NewKW: \$Revision\$" >>kwfile1.c &&
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 &&
331
348
echo "NewKW2: \$Revision:1\$" >>kwfile1.c &&
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.
350
test_expect_success 'merge conflict handling still works' '
351
test_when_finished cleanup_git &&
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"
359
"$GITP4" clone --dest="$git" //depot &&
362
sed -e "/Hello/d" merge2.c >merge2.c.tmp &&
363
mv merge2.c.tmp merge2.c &&
365
git commit -m "Modifying merge2.c"
369
p4 delete merge2.c &&
370
p4 submit -d "remove merge test file"
375
git config git-p4.skipSubmitEdit true &&
376
git config git-p4.attemptRCSCleanup true &&
377
!(echo "s" | "$GITP4" submit) &&
384
363
test_expect_success 'kill p4d' '