[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 70ff074 2/5: Check that compared files are on the same hos
From: |
Alexey Veretennikov |
Subject: |
[elpa] master 70ff074 2/5: Check that compared files are on the same host |
Date: |
Sat, 24 Sep 2016 17:52:13 +0000 (UTC) |
branch: master
commit 70ff0747e5d71cebc3ff1228d2d5dee7b83dbe3e
Author: Philippe Vaucher <address@hidden>
Commit: Philippe Vaucher <address@hidden>
Check that compared files are on the same host
---
ztree-diff-model.el | 6 ++----
ztree-diff.el | 2 ++
ztree-util.el | 6 ++++++
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/ztree-diff-model.el b/ztree-diff-model.el
index 25f9c26..2e06b80 100644
--- a/ztree-diff-model.el
+++ b/ztree-diff-model.el
@@ -141,10 +141,8 @@ RIGHT if only on the right side."
(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).
+ (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 --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 17f6218..c637e8f 100644
--- a/ztree-util.el
+++ b/ztree-util.el
@@ -80,6 +80,12 @@ Used since `car-safe' returns nil for atoms"
"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