unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: Greg Pfeil <greg@technomadic.org>
Cc: 60943@debbugs.gnu.org
Subject: bug#60943: 28.2; ‘tramp-handle-file-regular-p’ misses symlinks
Date: Thu, 19 Jan 2023 14:12:24 +0100	[thread overview]
Message-ID: <87fsc6llc7.fsf@gmx.de> (raw)
In-Reply-To: <A663E0C5-E498-4C94-8799-38A59AE55263@technomadic.org> (Greg Pfeil's message of "Wed, 18 Jan 2023 23:03:34 -0700")

[-- Attachment #1: Type: text/plain, Size: 1007 bytes --]

Greg Pfeil <greg@technomadic.org> writes:

Hi Greg,

> I was having an issue where .dir-locals.el on remote machines weren’t getting picked up when they were a symlink. Local symlinks worked fine, and remote non-symlinks also worked.
>
> Digging in, ‘tramp-handle-regular-file-p’ explicitly checks that the first character in ‘file-attribute-mode’ is ?-. However, for symlinks, that character will be ?l.
>
> Modifying ‘dir-locals--all-files’ to check
>
>   (or (file-regular-p f) (file-symlink-p f))
>
> \(which is ostensibly redundant) instead of simply
>
>   (file-regular-p f)

Indeed, there's a bug. Thanks for the report!

> fixes the behavior, since TRAMP will now check with both ‘tramp-handle-file-regular-p’ and ‘tramp-handle-file-symlink-p’. The correct fix is to make ‘tramp-handle-file-regular-p’ match the behavior of ‘file-regular-p’.

The appended patch fixes this. Eli, is it OK to push to the emacs-29 branch?

Best regards, Michael.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 688 bytes --]

diff --git a/lisp/tramp.el b/lisp/tramp.el
index 351def66..f5208cd9 100644
--- a/lisp/tramp.el
+++ b/lisp/tramp.el
@@ -4039,7 +4039,10 @@ Let-bind it when necessary.")
        ;; Sometimes, `file-attributes' does not return a proper value
        ;; even if `file-exists-p' does.
        (when-let ((attr (file-attributes filename)))
-	 (eq ?- (aref (file-attribute-modes attr) 0)))))
+	 (cond
+	  ((eq ?- (aref (file-attribute-modes attr) 0)))
+	  ((eq ?l (aref (file-attribute-modes attr) 0))
+	   (file-regular-p (file-truename filename)))))))

 (defun tramp-handle-file-remote-p (filename &optional identification connected)
   "Like `file-remote-p' for Tramp files."

  reply	other threads:[~2023-01-19 13:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-19  6:03 bug#60943: 28.2; ‘tramp-handle-file-regular-p’ misses symlinks Greg Pfeil
2023-01-19 13:12 ` Michael Albinus [this message]
2023-01-19 17:55   ` Greg Pfeil
2023-01-20 10:56     ` Michael Albinus
2023-01-20 14:16       ` Greg Pfeil
2023-01-21 11:13         ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fsc6llc7.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=60943@debbugs.gnu.org \
    --cc=greg@technomadic.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).