{"thread":{"id":"9424","subject":"[PATCH] git-p4: Fix support for symlinks.","startedAt":"2007-08-07T10:28:00Z","lastAt":"2007-08-07T10:28:00Z","messageCount":1,"participants":["Simon Hausmann"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"50111","messageId":"200708071228.07645.simon@lst.de","threadId":"9424","inReplyTo":null,"subject":"[PATCH] git-p4: Fix support for symlinks.","fromName":"Simon Hausmann","fromEmail":"simon@lst.de","sentAt":"2007-08-07T10:28:00Z","receivedAt":"2007-08-07T10:28:00Z","isPatch":true,"sender":{"key":"hausmann@kde.org","avatar":"https://gravatar.com/avatar/bc9aad4fb31dce17eb66e690e7b51fe980c62da3c225c785da35dd806b8da778?d=mp&s=160"},"body":"Detect symlinks as file type, set the git file mode accordingly and strip off the trailing newline in the p4 print output.\nMake the mode handling a bit more readable at the same time.\n\nSigned-off-by: Simon Hausmann <simon@lst.de>\nAcked-by: Brian Swetland <swetland@google.com>\n---\n contrib/fast-import/git-p4 |   14 +++++++++-----\n 1 files changed, 9 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\nindex 41e86e7..3cbb2da 100755\n--- a/contrib/fast-import/git-p4\n+++ b/contrib/fast-import/git-p4\n@@ -839,16 +839,20 @@ class P4Sync(Command):\n             if file[\"action\"] == \"delete\":\n                 self.gitStream.write(\"D %s\\n\" % relPath)\n             else:\n-                mode = 644\n-                if file[\"type\"].startswith(\"x\"):\n-                    mode = 755\n-\n                 data = file['data']\n \n+                mode = \"644\"\n+                if file[\"type\"].startswith(\"x\"):\n+                    mode = \"755\"\n+                elif file[\"type\"] == \"symlink\":\n+                    mode = \"120000\"\n+                    # p4 print on a symlink contains \"target\\n\", so strip it off\n+                    data = data[:-1]\n+\n                 if self.isWindows and file[\"type\"].endswith(\"text\"):\n                     data = data.replace(\"\\r\\n\", \"\\n\")\n \n-                self.gitStream.write(\"M %d inline %s\\n\" % (mode, relPath))\n+                self.gitStream.write(\"M %s inline %s\\n\" % (mode, relPath))\n                 self.gitStream.write(\"data %s\\n\" % len(data))\n                 self.gitStream.write(data)\n                 self.gitStream.write(\"\\n\")\n-- \n1.5.3.rc3.91.g5c75\n"}]}