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 <ajuncu@ixiacom.com> Signed-off-by: Alex Badea <abadea@ixiacom.com> Acked-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Alexandru Juncu committed
Aug 8, 2013 at 16:17 UTC
1292df11e8063442f911b2a4d0f7213f117d54d7
1 file changed
+6
-2
git-p4.py
+6
-2
@@ -2180,9 +2180,13 @@ class P4Sync(Command, P4UserMap):
2180
git_mode = "100755"
2181
if type_base == "symlink":
2182
git_mode = "120000"
2183
- # p4 print on a symlink contains "target\n"; remove the newline
2183
+ # p4 print on a symlink sometimes contains "target\n";
2184
+ # if it does, remove the newline
2185
data = ''.join(contents)
2185
- contents = [data[:-1]]
2186
+ if data[-1] == '\n':
2187
+ contents = [data[:-1]]
2188
+ else:
2189
+ contents = [data]
2190
2191
if type_base == "utf16":
2192
# p4 delivers different text in the python output to -G