git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-p4: Fix occasional truncation of symlink contents.

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 12, 2013, 17:11 UTC
Message-ID
<7v4nau25rc.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20130812123850.GA25532@padd.com>
Pete Wyckoff <pw@padd.com> writes:
> You should send the patch to junio for inclusion in pu/ for the
> next release, with:
>
> Acked-by: Pete Wyckoff <pw@padd.com>
Thanks; I'll queue this then.
-- >8 --
From: Alexandru Juncu <alexj@rosedu.org>
Date: Thu, 8 Aug 2013 16:17:38 +0300
Subject: [PATCH] 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>
---
 git-p4.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/git-p4.py b/git-p4.py
index 31e71ff..a53a6dc 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -2180,9 +2180,13 @@ class P4Sync(Command, P4UserMap):
             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
-- 
1.8.4-rc2-235-g32b7467
Previous: Alexandru Juncu
Message 6 of 6 in “git-p4: Fix occasional truncation of symlink contents.”
  1. git-p4: Fix occasional truncation of symlink contents.Alexandru Juncu, Aug 8, 2013
  2. Pete WyckoffAug 11, 2013
  3. Alexandru JuncuAug 12, 2013
  4. Pete WyckoffAug 12, 2013
  5. Alexandru JuncuAug 12, 2013
  6. Junio C HamanoAug 12, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.