summaryrefslogtreecommitdiff
path: root/contrib/fast-import
diff options
context:
space:
mode:
authorSimon Hausmann <simon@lst.de>2007-08-07 10:28:00 (GMT)
committerJunio C Hamano <gitster@pobox.com>2007-08-08 08:58:05 (GMT)
commit74276ec6f2d2123714066cee24b26a629930e7a8 (patch)
tree318e0cf879a45d43e5e5e7addc36c6ff7a05a7f1 /contrib/fast-import
parent3671757546ce78bb04611aa5481c2aa77a1ffc90 (diff)
downloadgit-74276ec6f2d2123714066cee24b26a629930e7a8.zip
git-74276ec6f2d2123714066cee24b26a629930e7a8.tar.gz
git-74276ec6f2d2123714066cee24b26a629930e7a8.tar.bz2
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>
Diffstat (limited to 'contrib/fast-import')
-rwxr-xr-xcontrib/fast-import/git-p414
1 files changed, 9 insertions, 5 deletions
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 41e86e7..3cbb2da 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -839,16 +839,20 @@ class P4Sync(Command):
if file["action"] == "delete":
self.gitStream.write("D %s\n" % relPath)
else:
- mode = 644
- if file["type"].startswith("x"):
- mode = 755
-
data = file['data']
+ mode = "644"
+ if file["type"].startswith("x"):
+ mode = "755"
+ 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")
- self.gitStream.write("M %d inline %s\n" % (mode, relPath))
+ self.gitStream.write("M %s inline %s\n" % (mode, relPath))
self.gitStream.write("data %s\n" % len(data))
self.gitStream.write(data)
self.gitStream.write("\n")