git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git-p4 and keyword expansion

From
Ddhruva <dhruva@ymail.com>
Date
Sep 8, 2008, 04:25 UTC
Message-ID
<554296.48174.qm@web95003.mail.in2.yahoo.com>
Hi,
 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'.
 Removing the keyword unexpanding code in 'git-p4' with the following patch makes it work:
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 2216cac..35c7914 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -975,10 +975,10 @@ class P4Sync(Command):
                 sys.stderr.write("p4 print fails with: %s\n" % repr(stat))
                 continue

-            if stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):
-                text = re.sub(r'(?i)\$(Id|Header):[^$]*\$',r'$\1$', text)
-            elif stat['type'] in ('text+k', 'ktext', 'kxtext', 'unicode+k', 'bi
-                text = re.sub(r'\$(Id|Header|Author|Date|DateTime|Change|File|R
+            #if stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):
+            #    text = re.sub(r'(?i)\$(Id|Header):[^$]*\$',r'$\1$', text)
+            #elif stat['type'] in ('text+k', 'ktext', 'kxtext', 'unicode+k', 'b
+            #    text = re.sub(r'\$(Id|Header|Author|Date|DateTime|Change|File|

             contents[stat['depotFile']] = text

Rationale:
1. The expanded keyword is stored in git repo
2. You edit the file and commit into git (the keyword does not change)
3. 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
4. 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..

I 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).

with best regards,
dhruva


      Connect with friends all over the world. Get Yahoo! India Messenger at http://in.messenger.yahoo.com/?wm=n/
Next: Tor Arvid Lund
Message 1 of 4 in “git-p4 and keyword expansion”
  1. dhruvaSep 8, 2008
  2. Tor Arvid LundSep 8, 2008
  3. Tor Arvid LundSep 8, 2008
  4. Jing XueSep 8, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.