branch: master commit 07009d7695eb7b82225712336fe388495dd48169 Merge: 272b515 70ff074 Author: Alexey Veretennikov <txm.four...@gmail.com> Commit: GitHub <nore...@github.com>
Merge pull request #33 from Silex/master Fix TRAMP regression --- ztree-diff-model.el | 25 ++++--------------------- ztree-diff.el | 2 ++ ztree-util.el | 21 +++++++++++++++++++++ 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/ztree-diff-model.el b/ztree-diff-model.el index b4ad75f..2e06b80 100644 --- a/ztree-diff-model.el +++ b/ztree-diff-model.el @@ -138,30 +138,13 @@ RIGHT if only on the right side." (string-equal (ztree-diff-node-right-path node1) (ztree-diff-node-right-path node1)))) -(defun ztree-diff-untrampify-filename (file) - "Return FILE as the local file name." - ;; FIXME: We shouldn't use internal Tramp functions. - (require 'tramp) - (declare-function tramp-tramp-file-p "tramp" (name)) - (declare-function tramp-file-name-localname "tramp" (vec)) - (declare-function tramp-dissect-file-name "tramp" (name &optional nodefault)) - (if (not (tramp-tramp-file-p file)) - file - (tramp-file-name-localname (tramp-dissect-file-name file)))) - -(defun ztree-diff-modef-quotify-string (x) - "Surround string X with quotes." - (concat "\"" x "\"")) - (defun ztree-diff-model-files-equal (file1 file2) "Compare files FILE1 and FILE2 using external diff. Returns t if equal." - ;; FIXME: This "untrampification" only works if both file1 and file2 are on - ;; the same host. - ;; FIXME: We assume that default-directory is also on the same host as - ;; file(1|2). - (let* ((file1-untrampified (ztree-diff-untrampify-filename (ztree-diff-modef-quotify-string file1))) - (file2-untrampified (ztree-diff-untrampify-filename (ztree-diff-modef-quotify-string file2))) + (unless (ztree-same-host-p file1 file2) + (error "Compared files are not on the same host")) + (let* ((file1-untrampified (ztree-quotify-string (ztree-untrampify-filename file1))) + (file2-untrampified (ztree-quotify-string (ztree-untrampify-filename file2))) (diff-command (concat diff-command " -q" " " file1-untrampified " " file2-untrampified)) (diff-output (shell-command-to-string diff-command))) (if (<= (length diff-output) 2) 'same 'diff))) diff --git a/ztree-diff.el b/ztree-diff.el index ed3d5f9..5ff3247 100644 --- a/ztree-diff.el +++ b/ztree-diff.el @@ -520,6 +520,8 @@ Argument DIR2 right directory." (error "Path %s is not a directory" dir2)) (unless (file-exists-p dir2) (error "Path %s does not exist" dir2)) + (unless (ztree-same-host-p dir1 dir2) + (error "Compared directories are not on the same host")) (let* ((model (ztree-diff-node-create nil dir1 dir2 nil)) (buf-name (concat "*" diff --git a/ztree-util.el b/ztree-util.el index ec49457..c637e8f 100644 --- a/ztree-util.el +++ b/ztree-util.el @@ -65,6 +65,27 @@ Used since `car-safe' returns nil for atoms" (insert text) (put-text-property start (point) 'face face))) +(defun ztree-untrampify-filename (file) + "Return FILE as the local file name." + ;; FIXME: We shouldn't use internal Tramp functions. + (require 'tramp) + (declare-function tramp-tramp-file-p "tramp" (name)) + (declare-function tramp-file-name-localname "tramp" (vec)) + (declare-function tramp-dissect-file-name "tramp" (name &optional nodefault)) + (if (not (tramp-tramp-file-p file)) + file + (tramp-file-name-localname (tramp-dissect-file-name file)))) + +(defun ztree-quotify-string (str) + "Surround STR with quotes." + (concat "\"" str "\"")) + +(defun ztree-same-host-p (file1 file2) + "Return t if FILE1 and FILE2 are on the same host." + (let ((file1-remote (file-remote-p file1)) + (file2-remote (file-remote-p file2))) + (string-equal file1-remote file2-remote))) + (provide 'ztree-util) ;;; ztree-util.el ends here