branch: externals/ztree
commit 369fd05e8a2d18679103e57d1a3f8dc689bb6eff
Author: Alexey Veretennikov <[email protected]>
Commit: Alexey Veretennikov <[email protected]>
Issue #50: Show file permission differences
Added variable ztree-diff-consider-file-permissions (turned off
by default) which controls whether file permissions shall
be taken into consideration when comparing files.
---
README.md | 2 ++
ztree-diff-model.el | 8 +++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 200843a..d7ac308 100644
--- a/README.md
+++ b/README.md
@@ -58,6 +58,8 @@ By default all files starting with dot (like `.gitignore`)
are not shown and exc
One also could turn on unicode characters to draw the tree with instead of
normal ASCII-characters. This is controlled by the `ztree-draw-unicode-lines`
variable.
+The variable `ztree-diff-consider-file-permissions` (which is `nil` by
default) if set to `t` allows to compare file attributes as well, the files
will be considered different if they have different mode.
+
### Screenshots

diff --git a/ztree-diff-model.el b/ztree-diff-model.el
index 6f4c951..d31ce34 100644
--- a/ztree-diff-model.el
+++ b/ztree-diff-model.el
@@ -33,6 +33,9 @@
(require 'ztree-util)
(eval-when-compile (require 'cl-lib))
+(defvar ztree-diff-consider-file-permissions nil
+ "Mark files as different if their permissions are different")
+
(defvar-local ztree-diff-model-ignore-fun nil
"Function which determines if the node should be excluded from comparison.")
@@ -147,7 +150,10 @@ Returns t if equal."
(file2-untrampified (ztree-untrampify-filename file2)))
(if (or
(/= (nth 7 (file-attributes file1))
- (nth 7 (file-attributes file2)))
+ (nth 7 (file-attributes file2)))
+ (and ztree-diff-consider-file-permissions
+ (not (string-equal (nth 8 (file-attributes file1))
+ (nth 8 (file-attributes file2)))))
(/= 0 (process-file diff-command nil nil nil "-q"
file1-untrampified
file2-untrampified)))