From: Alexandru Juncu Date: Thu, 8 Aug 2013 13:17:38 +0000 (+0300) Subject: git-p4: Fix occasional truncation of symlink contents. X-Git-Tag: v1.8.5-rc0~184^2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/1292df11e8063442f911b2a4d0f7213f117d54d7?ds=sidebyside git-p4: Fix occasional truncation of symlink contents. Symlink contents in p4 print sometimes have a trailing new line character, but sometimes it doesn't. git-p4 should only remove the last character if that character is '\n'. Signed-off-by: Alex Juncu Signed-off-by: Alex Badea Acked-by: Pete Wyckoff Signed-off-by: Junio C Hamano --- diff --git a/git-p4.py b/git-p4.py index 31e71ff8b2..a53a6dc406 100755 --- a/git-p4.py +++ b/git-p4.py @@ -2180,9 +2180,13 @@ def streamOneP4File(self, file, contents): git_mode = "100755" if type_base == "symlink": git_mode = "120000" - # p4 print on a symlink contains "target\n"; remove the newline + # p4 print on a symlink sometimes contains "target\n"; + # if it does, remove the newline data = ''.join(contents) - contents = [data[:-1]] + if data[-1] == '\n': + contents = [data[:-1]] + else: + contents = [data] if type_base == "utf16": # p4 delivers different text in the python output to -G