{"thread":{"id":"32014","subject":"[PATCH] git p4: RCS expansion should not span newlines","startedAt":"2012-11-04T22:04:02Z","lastAt":"2012-11-08T17:47:27Z","messageCount":2,"participants":["Pete Wyckoff","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"202525","messageId":"20121104220402.GA9160@padd.com","threadId":"32014","inReplyTo":"CACtYWOYOSxmogJHy70McsRVf0m2PVuu=q+pDZ2-gAza7vpeEiA@mail.gmail.com","subject":"[PATCH] git p4: RCS expansion should not span newlines","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-11-04T22:04:02Z","receivedAt":"2012-11-04T22:04:02Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"This bug was introduced in cb585a9 (git-p4: keyword\nflattening fixes, 2011-10-16).  The newline character\nis indeed special, and $File$ expansions should not try\nto match across multiple lines.\n\nBased-on-patch-by: Chris Goard <cgoard@gmail.com>\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n\ncgoard@gmail.com wrote on Mon, 16 Jul 2012 12:49 -0700:\n> Hi. Noticed an apparent bug in git-p4 related to RCS keyword\n> expansion. Some files in our Perforce repository have malformed RCS\n> keywords, e.g. \"$Revision:\" without a closing $. Perforce doesn't\n> expand these, obviously, but when a change to this file is imported\n> into git, everything up to the next $, on another line much later in\n> the file, is deleted. Seems to be due to multi-line matching of RCS\n> keywords. One fix is:\n> \n> diff --git a/git-p4.py b/git-p4.py\n> index f895a24..ae7b431 100755\n> --- a/git-p4.py\n> +++ b/git-p4.py\n> @@ -215,7 +215,7 @@ def p4_keywords_regexp_for_type(base, type_mods):\n>          pattern = r\"\"\"\n>              \\$              # Starts with a dollar, followed by...\n>              (%s)            # one of the keywords, followed by...\n> -            (:[^$]+)?       # possibly an old expansion, followed by...\n> +            (:[^\\n$]+)?     # possibly an old expansion, followed by...\n>              \\$              # another dollar\n>              \"\"\" % kwords\n>          return pattern\n\nChris,\n\nI finally got around to building a test-case for this.  The bug\nhas been in since around 1.7.7, so I won't call this exactly\nurgent, even though it is blatantly buggy as is.\n\nWill try to get it into the next release.\n\nThanks,\n\n\t\t-- Pete\n\n git-p4.py             |  2 +-\n t/t9810-git-p4-rcs.sh | 19 +++++++++++++++++++\n 2 files changed, 20 insertions(+), 1 deletion(-)\n\ndiff --git a/git-p4.py b/git-p4.py\nindex 882b1bb..7d6c928 100755\n--- a/git-p4.py\n+++ b/git-p4.py\n@@ -227,7 +227,7 @@ def p4_keywords_regexp_for_type(base, type_mods):\n         pattern = r\"\"\"\n             \\$              # Starts with a dollar, followed by...\n             (%s)            # one of the keywords, followed by...\n-            (:[^$]+)?       # possibly an old expansion, followed by...\n+            (:[^$\\n]+)?     # possibly an old expansion, followed by...\n             \\$              # another dollar\n             \"\"\" % kwords\n         return pattern\ndiff --git a/t/t9810-git-p4-rcs.sh b/t/t9810-git-p4-rcs.sh\nindex fe30ad8..0c2fc3e 100755\n--- a/t/t9810-git-p4-rcs.sh\n+++ b/t/t9810-git-p4-rcs.sh\n@@ -155,6 +155,25 @@ test_expect_success 'cleanup after failure' '\n \t)\n '\n \n+# perl $File:: bug check\n+test_expect_success 'ktext expansion should not expand multi-line $File::' '\n+\t(\n+\t\tcd \"$cli\" &&\n+\t\tcat >lv.pm <<-\\EOF\n+\t\tmy $wanted = sub { my $f = $File::Find::name;\n+\t\t\t\t    if ( -f && $f =~ /foo/ ) {\n+\t\tEOF\n+\t\tp4 add -t ktext lv.pm &&\n+\t\tp4 submit -d \"lv.pm\"\n+\t) &&\n+\ttest_when_finished cleanup_git &&\n+\tgit p4 clone --dest=\"$git\" //depot &&\n+\t(\n+\t\tcd \"$git\" &&\n+\t\ttest_cmp \"$cli/lv.pm\" lv.pm\n+\t)\n+'\n+\n #\n # Do not scrub anything but +k or +ko files.  Sneak a change into\n # the cli file so that submit will get a conflict.  Make sure that\n-- \n1.7.12.1.457.g468b3ef\n"},{"id":"202658","messageId":"20121108174727.GJ15560@sigill.intra.peff.net","threadId":"32014","inReplyTo":"20121104220402.GA9160@padd.com","subject":"Re: [PATCH] git p4: RCS expansion should not span newlines","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-11-08T17:47:27Z","receivedAt":"2012-11-08T17:47:27Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Nov 04, 2012 at 05:04:02PM -0500, Pete Wyckoff wrote:\n\n> This bug was introduced in cb585a9 (git-p4: keyword\n> flattening fixes, 2011-10-16).  The newline character\n> is indeed special, and $File$ expansions should not try\n> to match across multiple lines.\n> \n> Based-on-patch-by: Chris Goard <cgoard@gmail.com>\n> Signed-off-by: Pete Wyckoff <pw@padd.com>\n\nThanks, I'll queue this for 'maint'. Seems obviously correct to me.\n\n-Peff\n"}]}