Work on Tramp's file-truename
* lisp/net/tramp-sh.el (tramp-perl-file-truename): Check also for symlinks. (tramp-sh-handle-file-truename): Move check for a symlink cycle to the end. Do not blame symlinks which look like a remote file name. * lisp/net/tramp.el (tramp-handle-file-truename): Expand result.
This commit is contained in:
parent
1a01423b3c
commit
40fdbb01d0
2 changed files with 12 additions and 20 deletions
|
@ -613,7 +613,7 @@ use Cwd \"realpath\";
|
||||||
|
|
||||||
sub myrealpath {
|
sub myrealpath {
|
||||||
my ($file) = @_;
|
my ($file) = @_;
|
||||||
return realpath($file) if -e $file;
|
return realpath($file) if (-e $file || -l $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub recursive {
|
sub recursive {
|
||||||
|
@ -1139,12 +1139,7 @@ component is used as the target of the symlink."
|
||||||
(tramp-shell-quote-argument localname)))
|
(tramp-shell-quote-argument localname)))
|
||||||
(with-current-buffer (tramp-get-connection-buffer v)
|
(with-current-buffer (tramp-get-connection-buffer v)
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(setq result (buffer-substring (point-min) (point-at-eol))))
|
(setq result (buffer-substring (point-min) (point-at-eol)))))
|
||||||
(when (and (file-symlink-p filename)
|
|
||||||
(string-equal result localname))
|
|
||||||
(tramp-error
|
|
||||||
v 'file-error
|
|
||||||
"Apparent cycle of symbolic links for %s" filename)))
|
|
||||||
|
|
||||||
;; Use Perl implementation.
|
;; Use Perl implementation.
|
||||||
((and (tramp-get-remote-perl v)
|
((and (tramp-get-remote-perl v)
|
||||||
|
@ -1198,16 +1193,6 @@ component is used as the target of the symlink."
|
||||||
(setq numchase (1+ numchase))
|
(setq numchase (1+ numchase))
|
||||||
(when (file-name-absolute-p symlink-target)
|
(when (file-name-absolute-p symlink-target)
|
||||||
(setq result nil))
|
(setq result nil))
|
||||||
;; If the symlink was absolute, we'll get a
|
|
||||||
;; string like "/user@host:/some/target";
|
|
||||||
;; extract the "/some/target" part from it.
|
|
||||||
(when (tramp-tramp-file-p symlink-target)
|
|
||||||
(unless (tramp-equal-remote filename symlink-target)
|
|
||||||
(tramp-error
|
|
||||||
v 'file-error
|
|
||||||
"Symlink target `%s' on wrong host"
|
|
||||||
symlink-target))
|
|
||||||
(setq symlink-target localname))
|
|
||||||
(setq steps
|
(setq steps
|
||||||
(append
|
(append
|
||||||
(split-string symlink-target "/" 'omit) steps)))
|
(split-string symlink-target "/" 'omit) steps)))
|
||||||
|
@ -1226,6 +1211,13 @@ component is used as the target of the symlink."
|
||||||
"/"))
|
"/"))
|
||||||
(when (string= "" result)
|
(when (string= "" result)
|
||||||
(setq result "/")))))
|
(setq result "/")))))
|
||||||
|
|
||||||
|
;; Detect cycle.
|
||||||
|
(when (and (file-symlink-p filename)
|
||||||
|
(string-equal result localname))
|
||||||
|
(tramp-error
|
||||||
|
v 'file-error
|
||||||
|
"Apparent cycle of symbolic links for %s" filename))
|
||||||
;; If the resulting localname looks remote, we must quote it
|
;; If the resulting localname looks remote, we must quote it
|
||||||
;; for security reasons.
|
;; for security reasons.
|
||||||
(when (or quoted (file-remote-p result))
|
(when (or quoted (file-remote-p result))
|
||||||
|
|
|
@ -3169,7 +3169,7 @@ User is always nil."
|
||||||
|
|
||||||
(defun tramp-handle-file-truename (filename)
|
(defun tramp-handle-file-truename (filename)
|
||||||
"Like `file-truename' for Tramp files."
|
"Like `file-truename' for Tramp files."
|
||||||
(let ((result filename)
|
(let ((result (expand-file-name filename))
|
||||||
(numchase 0)
|
(numchase 0)
|
||||||
;; Don't make the following value larger than
|
;; Don't make the following value larger than
|
||||||
;; necessary. People expect an error message in a
|
;; necessary. People expect an error message in a
|
||||||
|
@ -3180,7 +3180,7 @@ User is always nil."
|
||||||
symlink-target)
|
symlink-target)
|
||||||
(format
|
(format
|
||||||
"%s%s"
|
"%s%s"
|
||||||
(with-parsed-tramp-file-name (expand-file-name result) v1
|
(with-parsed-tramp-file-name result v1
|
||||||
(with-tramp-file-property v1 v1-localname "file-truename"
|
(with-tramp-file-property v1 v1-localname "file-truename"
|
||||||
(while (and (setq symlink-target (file-symlink-p result))
|
(while (and (setq symlink-target (file-symlink-p result))
|
||||||
(< numchase numchase-limit))
|
(< numchase numchase-limit))
|
||||||
|
@ -3850,7 +3850,7 @@ Erase echoed commands if exists."
|
||||||
(min (+ (point-min) tramp-echo-mark-marker-length)
|
(min (+ (point-min) tramp-echo-mark-marker-length)
|
||||||
(point-max))))))
|
(point-max))))))
|
||||||
;; No echo to be handled, now we can look for the regexp.
|
;; No echo to be handled, now we can look for the regexp.
|
||||||
;; Sometimes, lines are much to long, and we run into a "Stack
|
;; Sometimes, lines are much too long, and we run into a "Stack
|
||||||
;; overflow in regexp matcher". For example, //DIRED// lines of
|
;; overflow in regexp matcher". For example, //DIRED// lines of
|
||||||
;; directory listings with some thousand files. Therefore, we
|
;; directory listings with some thousand files. Therefore, we
|
||||||
;; look from the end.
|
;; look from the end.
|
||||||
|
|
Loading…
Add table
Reference in a new issue