git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pete Wyckoff <pw@padd.com>
To: "Damien Gérard" <damien@iwi.me>
Cc: git@vger.kernel.org, Alexandru Juncu <alexj@rosedu.org>
Subject: Re: git-p4: exception when cloning a perforce repository
Date: Sat, 18 Jan 2014 13:22:25 -0500	[thread overview]
Message-ID: <20140118182225.GA6072@padd.com> (raw)
In-Reply-To: <B6C98918-4339-4D14-8C52-4B3AEC2526E7@iwi.me>

damien@iwi.me wrote on Thu, 16 Jan 2014 17:02 +0100:
> 
> On 16 Jan 2014, at 15:45, Pete Wyckoff <pw@padd.com> wrote:
> 
> > Oh cool, that helps a lot.  P4 is just broken here, so we can get
> > away with being a bit sloppy in git.  I'll try just pretending
> > "empty symlinks" are not in the repo.  Hopefully you'll have a
> > future commit in your p4 repo that brings back bn.h properly.
> 
> Thanks !
> I would love to use git instead of perforce if possible :)
> 
> > Still not sure about how I'll test this.
> 
> I can test for you, no probleme with that.

Any chance you can give this a go?  I've a bigger patch in
a longer series, but this should be the minimal fix.  If it
works, I'll ship it to Junio.

Thanks,

		-- Pete

----8<--------

From 8556ab04dd126184e26a380b7ed08998fd33debe Mon Sep 17 00:00:00 2001
From: Pete Wyckoff <pw@padd.com>
Date: Thu, 16 Jan 2014 18:34:09 -0500
Subject: [PATCH] git p4: work around p4 bug that causes empty symlinks
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Damien Gérard highlights an interesting problem.  Some p4
repositories end up with symlinks that have an empty target.  It
is not possible to create this with current p4, but they do
indeed exist.

The effect in git p4 is that "p4 print" on the symlink returns an
empty string, confusing the curret symlink-handling code.

In p4, syncing to a change that includes such a bogus symlink
creates errors:

    //depot/empty-symlink - updating /home/me/p4/empty-symlink
    rename: /home/me/p4/empty-symlink: No such file or directory

and leaves no symlink.

Replicate the p4 behavior by ignoring these bogus symlinks.  If
they are fixed in later revisions, the symlink will be replaced
properly.

Reported-by: Damien Gérard <damien@iwi.me>
Signed-off-by: Pete Wyckoff <pw@padd.com>
---
 git-p4.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/git-p4.py b/git-p4.py
index 5ea8bb8..e798ecf 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -2075,7 +2075,14 @@ class P4Sync(Command, P4UserMap):
             # p4 print on a symlink sometimes contains "target\n";
             # if it does, remove the newline
             data = ''.join(contents)
-            if data[-1] == '\n':
+            if not data:
+                # Some version of p4 allowed creating a symlink that pointed
+                # to nothing.  This causes p4 errors when checking out such
+                # a change, and errors here too.  Work around it by ignoring
+                # the bad symlink; hopefully a future change fixes it.
+                print "\nIgnoring empty symlink in %s" % file['depotFile']
+                return
+            elif data[-1] == '\n':
                 contents = [data[:-1]]
             else:
                 contents = [data]
-- 
1.8.5.2.320.g99957e5

  reply	other threads:[~2014-01-18 18:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-13 13:37 git-p4: exception when cloning a perforce repository Damien Gérard
2014-01-14  0:18 ` Pete Wyckoff
2014-01-14 23:24   ` Pete Wyckoff
2014-01-15  8:56     ` Damien Gérard
2014-01-16 13:08       ` Pete Wyckoff
2014-01-16 13:46         ` Damien Gérard
2014-01-16 14:45           ` Pete Wyckoff
2014-01-16 16:02             ` Damien Gérard
2014-01-18 18:22               ` Pete Wyckoff [this message]
2014-01-20 12:14                 ` Damien Gérard
2014-01-20 14:01                 ` Damien Gérard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140118182225.GA6072@padd.com \
    --to=pw@padd.com \
    --cc=alexj@rosedu.org \
    --cc=damien@iwi.me \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).