Skip to content

Commit

Permalink
git p4: RCS expansion should not span newlines
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Pete Wyckoff authored and Jeff King committed Nov 8, 2012
1 parent 7e20105 commit 6b2bf41
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion git-p4.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def p4_keywords_regexp_for_type(base, type_mods):
pattern = r"""
\$ # Starts with a dollar, followed by...
(%s) # one of the keywords, followed by...
(:[^$]+)? # possibly an old expansion, followed by...
(:[^$\n]+)? # possibly an old expansion, followed by...
\$ # another dollar
""" % kwords
return pattern
Expand Down
19 changes: 19 additions & 0 deletions t/t9810-git-p4-rcs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,25 @@ test_expect_success 'cleanup after failure' '
)
'

# perl $File:: bug check
test_expect_success 'ktext expansion should not expand multi-line $File::' '
(
cd "$cli" &&
cat >lv.pm <<-\EOF
my $wanted = sub { my $f = $File::Find::name;
if ( -f && $f =~ /foo/ ) {
EOF
p4 add -t ktext lv.pm &&
p4 submit -d "lv.pm"
) &&
test_when_finished cleanup_git &&
git p4 clone --dest="$git" //depot &&
(
cd "$git" &&
test_cmp "$cli/lv.pm" lv.pm
)
'

#
# Do not scrub anything but +k or +ko files. Sneak a change into
# the cli file so that submit will get a conflict. Make sure that
Expand Down

0 comments on commit 6b2bf41

Please sign in to comment.