$OpenBSD: patch-files_ml,v 1.2 2005/05/30 19:27:45 sturm Exp $
Post-release developer patch.
o Fix substitution of CURRENT1 and CURRENT2 in diff command.
  See http://lists.seas.upenn.edu/pipermail/unison-hackers/2005-May/000091.html
o Fix the problem with comparison of files using diff
  when the files are on two different hosts.
  See http://groups.yahoo.com/group/unison-users/message/3877
--- files.ml.orig	Sat Mar 12 11:17:59 2005
+++ files.ml	Fri May 27 17:38:20 2005
@@ -429,8 +429,8 @@ let diffCmd =
      ^ "utility used to generate displays of file differences.  The default "
      ^ "is `\\verb|diff|'.  If the value of this preference contains the substrings "
      ^ "CURRENT1 and CURRENT2, these will be replaced by the names of the files to be "
-     ^ "diffed.  If not, the two filenames will be appended to the command (enclosed "
-     ^ "in double quotes).")
+     ^ "diffed.  If not, the two filenames will be appended to the command.  In both "
+     ^ "cases, the filenames are suitably quoted.")
 
 let quotes s = "'" ^ Util.replacesubstring s "'" "'\''" ^ "'"
 
@@ -442,14 +442,14 @@ let rec diff root1 path1 ui1 root2 path2
       (root2string root2) (Path.toString path2));
   let displayDiff fspath1 fspath2 =
     let cmd =
-      if Util.findsubstring (Prefs.read diffCmd) "CURRENT1" = None then
+      if Util.findsubstring "CURRENT1" (Prefs.read diffCmd) = None then
           (Prefs.read diffCmd)
         ^ " " ^ (quotes (Fspath.toString fspath1))
-        ^ " " ^ (quotes (Fspath.toString fspath2)) 
-      else 
+        ^ " " ^ (quotes (Fspath.toString fspath2))
+      else
         Util.replacesubstrings (Prefs.read diffCmd)
-          ["CURRENT1", (Fspath.toString fspath1);
-           "CURRENT2", (Fspath.toString fspath2)] in
+          ["CURRENT1", quotes (Fspath.toString fspath1);
+           "CURRENT2", quotes (Fspath.toString fspath2)] in
     let c = Unix.open_process_in cmd in
     showDiff cmd (readChannelTillEof c);
     ignore(Unix.close_process_in c) in
@@ -476,7 +476,7 @@ let rec diff root1 path1 ui1 root2 path2
              (Update.translatePath root2 path2 >>= (fun path2 ->
               Copy.file root2 path2 root1 workingDir tmppath realPath
                 `Copy (Props.setLength Props.fileSafe (Props.length desc2))
-                 fp1 ress1 id));
+                 fp2 ress2 id));
            displayDiff
 	     (Fspath.concat workingDir realPath)
              (Fspath.concat workingDir tmppath);
@@ -494,7 +494,7 @@ let rec diff root1 path1 ui1 root2 path2
               (* Note that we don't need the ressource fork *)
               Copy.file root1 path1 root2 workingDir tmppath realPath
                 `Copy (Props.setLength Props.fileSafe (Props.length desc1))
-                 fp2 ress2 id));
+                 fp1 ress1 id));
            displayDiff
              (Fspath.concat workingDir tmppath)
 	     (Fspath.concat workingDir realPath);
