git p4: RCS expansion should not span newlines
This bug was introduced in cb585a9 (git-p4: keyword flattening fixes, 2011-10-16). The newline character is indeed special, and $File$ expansions should not try to match across multiple lines. Based-on-patch-by: Chris Goard <cgoard@gmail.com> Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Jeff King <peff@peff.net>
Pete Wyckoff committed
Nov 4, 2012 at 17:04 UTC
6b2bf41e6c1c9742c5ad5b5920f48a7b23aa6a50
2 files changed
+20
-1
git-p4.py
+1
-1
@@ -227,7 +227,7 @@ def p4_keywords_regexp_for_type(base, type_mods):
227
pattern = r"""
228
\$ # Starts with a dollar, followed by...
229
(%s) # one of the keywords, followed by...
230
- (:[^$]+)? # possibly an old expansion, followed by...
230
+ (:[^$\n]+)? # possibly an old expansion, followed by...
231
\$ # another dollar
232
""" % kwords
233
return pattern
t/t9810-git-p4-rcs.sh
+19
@@ -155,6 +155,25 @@ test_expect_success 'cleanup after failure' '
155
)
156
'
157
158
+# perl $File:: bug check
159
+test_expect_success 'ktext expansion should not expand multi-line $File::' '
160
+ (
161
+ cd "$cli" &&
162
+ cat >lv.pm <<-\EOF
163
+ my $wanted = sub { my $f = $File::Find::name;
164
+ if ( -f && $f =~ /foo/ ) {
165
+ EOF
166
+ p4 add -t ktext lv.pm &&
167
+ p4 submit -d "lv.pm"
168
+ ) &&
169
+ test_when_finished cleanup_git &&
170
+ git p4 clone --dest="$git" //depot &&
171
+ (
172
+ cd "$git" &&
173
+ test_cmp "$cli/lv.pm" lv.pm
174
+ )
175
+'
176
+
177
#
178
# Do not scrub anything but +k or +ko files. Sneak a change into
179
# the cli file so that submit will get a conflict. Make sure that