@matheusbsbs / matheus-bagliano / commits / 74276ec6f2
Fork 0

git-p4: Fix support for symlinks.

Detect symlinks as file type, set the git file mode accordingly and strip off the trailing newline in the p4 print output. Make the mode handling a bit more readable at the same time. Signed-off-by: Simon Hausmann <simon@lst.de> Acked-by: Brian Swetland <swetland@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Simon Hausmann committed Aug 7, 2007 at 12:28 UTC 74276ec6f2d2123714066cee24b26a629930e7a8
1 file changed +9 -5
contrib/fast-import/git-p4
+9 -5
@@ -839,16 +839,20 @@ class P4Sync(Command):
839 if file["action"] == "delete":
840 self.gitStream.write("D %s\n" % relPath)
841 else:
842 - mode = 644
843 - if file["type"].startswith("x"):
844 - mode = 755
845 -
842 data = file['data']
843
844 + mode = "644"
845 + if file["type"].startswith("x"):
846 + mode = "755"
847 + elif file["type"] == "symlink":
848 + mode = "120000"
849 + # p4 print on a symlink contains "target\n", so strip it off
850 + data = data[:-1]
851 +
852 if self.isWindows and file["type"].endswith("text"):
853 data = data.replace("\r\n", "\n")
854
851 - self.gitStream.write("M %d inline %s\n" % (mode, relPath))
855 + self.gitStream.write("M %s inline %s\n" % (mode, relPath))
856 self.gitStream.write("data %s\n" % len(data))
857 self.gitStream.write(data)
858 self.gitStream.write("\n")