{"thread":{"id":"15417","subject":"git-p4 and keyword expansion","startedAt":"2008-09-08T04:25:25Z","lastAt":"2008-09-08T21:39:00Z","messageCount":4,"participants":["dhruva","Tor Arvid Lund","Jing Xue"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"90045","messageId":"554296.48174.qm@web95003.mail.in2.yahoo.com","threadId":"15417","inReplyTo":null,"subject":"git-p4 and keyword expansion","fromName":"dhruva","fromEmail":"dhruva@ymail.com","sentAt":"2008-09-08T04:25:25Z","receivedAt":"2008-09-08T04:25:25Z","isPatch":false,"sender":{"key":"dhruva@ymail.com","avatar":null},"body":"Hi,\n The git-p4 script unexpands all p4 keywords before feeding it to git fastimport. When there is a new version, it records only the diffs minus the keyword contents at it unexpands and then feeds to fastimport. When trying to submit back to perforce, applying a patch on top of the latest file in p4 with the keyword expanded fails because we have not tracked that difference. Patch applying fails and expects you to manually (out of git) to do a 'p4 submit' and get back and do 'git-p4 submit --continue'.\n Removing the keyword unexpanding code in 'git-p4' with the following patch makes it work:\ndiff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\nindex 2216cac..35c7914 100755\n--- a/contrib/fast-import/git-p4\n+++ b/contrib/fast-import/git-p4\n@@ -975,10 +975,10 @@ 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-                text = re.sub(r'(?i)\\$(Id|Header):[^$]*\\$',r'$\\1$', text)\n-            elif stat['type'] in ('text+k', 'ktext', 'kxtext', 'unicode+k', 'bi\n-                text = re.sub(r'\\$(Id|Header|Author|Date|DateTime|Change|File|R\n+            #if 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', 'b\n+            #    text = re.sub(r'\\$(Id|Header|Author|Date|DateTime|Change|File|\n\n             contents[stat['depotFile']] = text\n\nRationale:\n1. The expanded keyword is stored in git repo\n2. You edit the file and commit into git (the keyword does not change)\n3. When a new version of the same file comes from p4 (through git-p4 sync), it will have a new keyword content. Hence, the keyword change is tracked and 'git-p4 rebase' can apply the patch with not hunk rejections\n4. When comitting back to p4 through 'git-p4 submit', the change in keyword contents are tracked and there is a hunk for it. Therefore, the patch applies cleanly and submit goes through..\n\nI am looking for feedback/suggestions on this. I am planning to use git-p4 on production level and am trying to seel to company wide (quite a large group) as an alternative to p4 (still using p4 as final centralized backend to satisfy the management).\n\nwith best regards,\ndhruva\n\n\n      Connect with friends all over the world. Get Yahoo! India Messenger at http://in.messenger.yahoo.com/?wm=n/\n"},{"id":"90060","messageId":"1a6be5fa0809080127h5db71093o364aade2fb955acc@mail.gmail.com","threadId":"15417","inReplyTo":"554296.48174.qm@web95003.mail.in2.yahoo.com","subject":"Re: git-p4 and keyword expansion","fromName":"Tor Arvid Lund","fromEmail":"torarvid@gmail.com","sentAt":"2008-09-08T08:27:02Z","receivedAt":"2008-09-08T08:27:02Z","isPatch":false,"sender":{"key":"torarvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/439758?v=4"},"body":"Hi,\n\nOn Mon, Sep 8, 2008 at 6:25 AM, dhruva <dhruva@ymail.com> wrote:\n> Hi,\n>  The git-p4 script unexpands all p4 keywords before feeding it to git fastimport. When there is a new version, it records only the diffs minus the keyword contents at it unexpands and then feeds to fastimport. When trying to submit back to perforce, applying a patch on top of the latest file in p4 with the keyword expanded fails because we have not tracked that difference. Patch applying fails and expects you to manually (out of git) to do a 'p4 submit' and get back and do 'git-p4 submit --continue'.\n>  Removing the keyword unexpanding code in 'git-p4' with the following patch makes it work:\n\nYes, I have also experienced this problem, and haven't yet come up\nwith a solution to it. Your solution seems to solve the problem with\nsubmitting to p4, but it would also mean that files cloned from p4\nwould have diffs in the git database whenever the p4 headers changed.\nThis does not seem nice to me. Are all the keyword expansions\nreproducable? I mean... could we store them in git as before\n(unexpanded), and make some logic to recreate them upon submitting to\np4? That might work...\n\nI think, at least, that although this is a nice initiative, we should\nfind a nicer solution.\n\n-Tor Arvid-\n"},{"id":"90061","messageId":"1a6be5fa0809080137r622e9492ob72b6d2239311631@mail.gmail.com","threadId":"15417","inReplyTo":"1a6be5fa0809080127h5db71093o364aade2fb955acc@mail.gmail.com","subject":"Re: git-p4 and keyword expansion","fromName":"Tor Arvid Lund","fromEmail":"torarvid@gmail.com","sentAt":"2008-09-08T08:37:05Z","receivedAt":"2008-09-08T08:37:05Z","isPatch":false,"sender":{"key":"torarvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/439758?v=4"},"body":"On Mon, Sep 8, 2008 at 10:27 AM, Tor Arvid Lund <torarvid@gmail.com> wrote:\n> Hi,\n>\n> On Mon, Sep 8, 2008 at 6:25 AM, dhruva <dhruva@ymail.com> wrote:\n>> Hi,\n>>  The git-p4 script unexpands all p4 keywords before feeding it to git fastimport. When there is a new version, it records only the diffs minus the keyword contents at it unexpands and then feeds to fastimport. When trying to submit back to perforce, applying a patch on top of the latest file in p4 with the keyword expanded fails because we have not tracked that difference. Patch applying fails and expects you to manually (out of git) to do a 'p4 submit' and get back and do 'git-p4 submit --continue'.\n>>  Removing the keyword unexpanding code in 'git-p4' with the following patch makes it work:\n>\n> Yes, I have also experienced this problem, and haven't yet come up\n> with a solution to it. Your solution seems to solve the problem with\n> submitting to p4, but it would also mean that files cloned from p4\n> would have diffs in the git database whenever the p4 headers changed.\n\nHmm... Now that I think about it... Maybe we _want_ the extra diff\nhunks... Personally I don't care much for the keyword expansions, but\nsince they're there in p4, and p4 diff shows a diff hunk there, maybe\nwe should just do the same. In which case your original patch might be\njust fine. I realise I haven't had my morning coffee yet. Me\nconfused... :-/\n\n-TA-\n"},{"id":"90137","messageId":"20080908173900.102324atjr5geizo@intranet.digizenstudio.com","threadId":"15417","inReplyTo":"554296.48174.qm@web95003.mail.in2.yahoo.com","subject":"Re: git-p4 and keyword expansion","fromName":"Jing Xue","fromEmail":"jingxue@digizenstudio.com","sentAt":"2008-09-08T21:39:00Z","receivedAt":"2008-09-08T21:39:00Z","isPatch":false,"sender":{"key":"jingxue@digizenstudio.com","avatar":null},"body":"Quoting dhruva <dhruva@ymail.com>:\n\n> Hi,\n>  The git-p4 script unexpands all p4 keywords before feeding it to  \n> git fastimport. When there is a new version, it records only the  \n> diffs minus the keyword contents at it unexpands and then feeds to  \n> fastimport. When trying to submit back to perforce, applying a patch  \n> on top of the latest file in p4 with the keyword expanded fails  \n> because we have not tracked that difference.\n> Patch applying fails and expects you to manually (out of git) to do  \n> a 'p4 submit' and get back and do 'git-p4 submit --continue'.\n>  Removing the keyword unexpanding code in 'git-p4' with the  \n> following patch makes it work:\n\nI'm not really arguing against the patch itself, but just wondering  \nwhether it would be a good idea to make it optional or configurable.\n\nIIUC, there are reasons for git to discourage keyword expansion - for  \ninstance as discussed in this thread:\n\nhttp://kerneltrap.org/mailarchive/git/2007/10/11/335112\n\nCheers.\n-- \nJing Xue\n\n----------------------------------------------------------------\nThis message was sent using IMP, the Internet Messaging Program.\n"}]}