git p4 test: explicitly check p4 wildcard delete
[gitweb.git] / git-p4.py
index 06a3cc6122410efcccf0fd77f359ffc2e809aff9..e798ecf48c6c85066c2b90706bc8026f82bd34fb 100755 (executable)
--- a/git-p4.py
+++ b/git-p4.py
@@ -1311,7 +1311,7 @@ def applyCommit(self, id):
             else:
                 die("unknown modifier %s for %s" % (modifier, path))
 
-        diffcmd = "git format-patch -k --stdout \"%s^\"..\"%s\"" % (id, id)
+        diffcmd = "git diff-tree -p \"%s\"" % (id)
         patchcmd = diffcmd + " | git apply "
         tryPatchCmd = patchcmd + "--check -"
         applyPatchCmd = patchcmd + "--check --apply -"
@@ -2075,7 +2075,14 @@ def streamOneP4File(self, file, contents):
             # 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]