git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-p4: Fix support for symlinks.
@ 2007-08-07 10:28 Simon Hausmann
  0 siblings, 0 replies; 5+ messages in thread
From: Simon Hausmann @ 2007-08-07 10:28 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

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>
---
 contrib/fast-import/git-p4 |   14 +++++++++-----
 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")
-- 
1.5.3.rc3.91.g5c75

^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [PATCH] git-p4: Fix support for symlinks.
@ 2007-08-07  8:25 Simon Hausmann
  2007-08-07  8:40 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Simon Hausmann @ 2007-08-07  8:25 UTC (permalink / raw)
  To: git; +Cc: Han-Wen Nienhuys, Brian Swetland

[-- Attachment #1: Type: text/plain, Size: 1174 bytes --]

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 <simon@lst.de>
---
 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


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-08-08  1:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-07 10:28 [PATCH] git-p4: Fix support for symlinks Simon Hausmann
  -- strict thread matches above, loose matches on Subject: below --
2007-08-07  8:25 Simon Hausmann
2007-08-07  8:40 ` Junio C Hamano
2007-08-07  9:10   ` Brian Swetland
2007-08-08  1:36     ` Scott Lamb

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).