Skip to content

Commit 6b2bf41

Browse files
Pete Wyckoffpeff
authored andcommitted
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 <[email protected]> Signed-off-by: Pete Wyckoff <[email protected]> Signed-off-by: Jeff King <[email protected]>
1 parent 7e20105 commit 6b2bf41

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

git-p4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def p4_keywords_regexp_for_type(base, type_mods):
227227
pattern = r"""
228228
\$ # Starts with a dollar, followed by...
229229
(%s) # one of the keywords, followed by...
230-
(:[^$]+)? # possibly an old expansion, followed by...
230+
(:[^$\n]+)? # possibly an old expansion, followed by...
231231
\$ # another dollar
232232
""" % kwords
233233
return pattern

t/t9810-git-p4-rcs.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,25 @@ test_expect_success 'cleanup after failure' '
155155
)
156156
'
157157

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+
158177
#
159178
# Do not scrub anything but +k or +ko files. Sneak a change into
160179
# the cli file so that submit will get a conflict. Make sure that

0 commit comments

Comments
 (0)