{"thread":{"id":"15526","subject":"[PATCH] Optional shrinking of RCS keywords in git-p4","startedAt":"2008-09-15T05:58:51Z","lastAt":"2008-09-15T06:17:19Z","messageCount":3,"participants":["Dhruva Krishnamurthy","David Brown","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"90707","messageId":"1221458331-8804-1-git-send-email-dhruva@ymail.com","threadId":"15526","inReplyTo":null,"subject":"[PATCH] Optional shrinking of RCS keywords in git-p4","fromName":"Dhruva Krishnamurthy","fromEmail":"dhruva@ymail.com","sentAt":"2008-09-15T05:58:51Z","receivedAt":"2008-09-15T05:58:51Z","isPatch":true,"sender":{"key":"dhruva@ymail.com","avatar":null},"body":"Modifying RCS keywords prevents submitting to p4 from git due to missing hunks.\nNew option git-p4.kwstrip set to true or false controls the behavior.\n\nSigned-off-by: Dhruva Krishnamurthy <dhruva@ymail.com>\n---\n contrib/fast-import/git-p4 |   17 ++++++++++++++++-\n 1 files changed, 16 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\nindex 2216cac..ac8b7f7 100755\n--- a/contrib/fast-import/git-p4\n+++ b/contrib/fast-import/git-p4\n@@ -16,6 +16,9 @@ from sets import Set;\n \n verbose = False\n \n+# Handling of RCS keyowrds. To ensure backward compatibility, the default\n+# is to strip keywords. Default behavior is controlled here\n+kwstrip = True\n \n def p4_build_cmd(cmd):\n     \"\"\"Build a suitable p4 command line.\n@@ -975,7 +978,9 @@ class P4Sync(Command):\n                 sys.stderr.write(\"p4 print fails with: %s\\n\" % repr(stat))\n                 continue\n \n-            if stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):\n+            if not kwstrip:\n+\t\tpass\n+            elif stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):\n                 text = re.sub(r'(?i)\\$(Id|Header):[^$]*\\$',r'$\\1$', text)\n             elif stat['type'] in ('text+k', 'ktext', 'kxtext', 'unicode+k', 'binary+k'):\n                 text = re.sub(r'\\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\\$',r'$\\1$', text)\n@@ -1850,6 +1855,16 @@ def main():\n         (cmd, args) = parser.parse_args(sys.argv[2:], cmd);\n     global verbose\n     verbose = cmd.verbose\n+\n+    global kwstrip\n+    kwval = gitConfig(\"git-p4.kwstrip\")\n+    if len(kwval) > 0:\n+\tkwval = kwval.lower();\n+        if kwval == \"false\":\n+            kwstrip = False\n+        elif kwval == \"true\":\n+            kwstrip = True\n+\n     if cmd.needsGit:\n         if cmd.gitdir == None:\n             cmd.gitdir = os.path.abspath(\".git\")\n-- \n1.6.0.1.454.g63d55\n"},{"id":"90709","messageId":"20080915060954.GA32347@linode.davidb.org","threadId":"15526","inReplyTo":"1221458331-8804-1-git-send-email-dhruva@ymail.com","subject":"Re: [PATCH] Optional shrinking of RCS keywords in git-p4","fromName":"David Brown","fromEmail":"git@davidb.org","sentAt":"2008-09-15T06:09:55Z","receivedAt":"2008-09-15T06:09:55Z","isPatch":true,"sender":{"key":"git@davidb.org","avatar":"https://gravatar.com/avatar/94c86a2938470a74c2eac5e2b69afc0871f79a660295c02219597aba8cb101c1?d=mp&s=160"},"body":"On Mon, Sep 15, 2008 at 11:28:51AM +0530, Dhruva Krishnamurthy wrote:\n\n>Modifying RCS keywords prevents submitting to p4 from git due to missing hunks.\n>New option git-p4.kwstrip set to true or false controls the behavior.\n\nI'm a little curious about what the problem here is.  I've been\nstripping keywords out of P4 and submitting changes for many years,\nand never had a problem.\n\nI'm just wondering if we're not fixing the wrong problem here.\n\nDavid\n"},{"id":"90710","messageId":"7v4p4iexw0.fsf@gitster.siamese.dyndns.org","threadId":"15526","inReplyTo":"1221458331-8804-1-git-send-email-dhruva@ymail.com","subject":"Re: [PATCH] Optional shrinking of RCS keywords in git-p4","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-15T06:17:19Z","receivedAt":"2008-09-15T06:17:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dhruva Krishnamurthy <dhruva@ymail.com> writes:\n\n> Modifying RCS keywords prevents submitting to p4 from git due to missing hunks.\n\nHmm.  How are \"missing hunks\" caused?  Do you mean:\n\n - the substituted values from the expanded keywords are stripped out by\n   default (with kwstrip=True) when you check out from p4;\n\n - when you submit your changes back, p4 side expects you to send the file\n   with keywords just as it originally expanded;\n\nand this causes the contents mismatch, leading p4 to reject your change?\n\nThe patch itself looks fine; I just wanted to make sure commit log\nexplains what was fixed.\n"}]}