Subject: [PATCH] git-p4: Fix support for symlinks.

From: Simon Hausmann <[email-masked]>
Date: Tue, 7 Aug 2007 10:25:47 +0200

Detect symlinks as file type, set the git file mode accordingly and strip off the trailing newline in the p4 print output.

Signed-off-by: Simon Hausmann <[email-masked]>
---
 contrib/fast-import/git-p4 |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 41e86e7..9c6f911 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -839,11 +839,15 @@ class P4Sync(Command):
             if file["action"] == "delete":
                 self.gitStream.write("D %s\n" % relPath)
             else:
+                data = file['data']
+
                 mode = 644
                 if file["type"].startswith("x"):
                     mode = 755
-
-                data = file['data']
+                elif file["type"] == "symlink":
+                    mode = 120000
+                    # p4 print on a symlink contains "target\n", so strip it off
+                    data = data[:-1]
 
                 if self.isWindows and file["type"].endswith("text"):
                     data = data.replace("\r\n", "\n")
-- 
1.5.3.rc3.91.g5c75