diff options
| author | Paul Eggert | 2020-03-07 12:04:05 -0800 |
|---|---|---|
| committer | Paul Eggert | 2020-03-07 12:15:43 -0800 |
| commit | 5d4cf1fef85bc24bc4cd9705ebb14150263ad707 (patch) | |
| tree | af696ed3ba7d2d0ab31951eba9482443d36c1456 /lisp/net | |
| parent | 9f4b260c2b98ea05a02e0ab7213156ce2e60e5a9 (diff) | |
| download | emacs-5d4cf1fef85bc24bc4cd9705ebb14150263ad707.tar.gz emacs-5d4cf1fef85bc24bc4cd9705ebb14150263ad707.zip | |
Add ‘nofollow’ flag to set-file-times
This is a companion to the recent set-file-modes patch.
It adds support for a ‘nofollow’ flag to set-file-times (Bug#39773).
Like the set-file-modes patch, it needs work in the w32 port.
* admin/merge-gnulib (GNULIB_MODULES): Add futimens, utimensat.
Remove utimens.
* doc/lispref/files.texi (Changing Files):
* etc/NEWS: Mention the change.
* lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
* lisp/files.el (copy-directory):
* lisp/gnus/gnus-cloud.el (gnus-cloud-replace-file):
* lisp/net/tramp-adb.el (tramp-adb-handle-copy-file):
* lisp/net/tramp-smb.el (tramp-smb-handle-copy-file):
* lisp/tar-mode.el (tar-copy):
* test/lisp/filenotify-tests.el (file-notify-test03-events):
* test/lisp/files-tests.el:
(files-tests-file-name-non-special-set-file-times):
* test/lisp/net/tramp-tests.el (tramp-test22-file-times):
When setting file times, avoid following symbolic links
when the file is not supposed to be a symbolic link.
* lib/futimens.c, lib/utimensat.c, m4/futimens.m4, m4/utimensat.m4:
New files, copied from Gnulib.
* lisp/gnus/gnus-cloud.el (gnus-cloud-replace-file):
When creating a file that is not supposed to exist already,
use the excl flag to check this.
* lisp/net/tramp-adb.el (tramp-adb-handle-set-file-times):
* lisp/net/tramp-sh.el (tramp-sh-handle-set-file-times):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-handle-set-file-times):
Accept an optional FLAG arg that is currently ignored,
and add a FIXME comment for it.
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-set-file-times):
* src/fileio.c (Fset_file_times):
Support an optional FLAG arg.
* src/fileio.c (Fcopy_file): Use futimens instead of set_file_times,
as it’s simpler and is a POSIX API.
* src/sysdep.c (set_file_times): Move from here ...
* src/w32.c (set_file_times): ... to here, and make it static,
since it is now used only in w32.c. Presumably w32.c should also
add support for futimens and utimensat (the POSIX APIs, which
Emacs now uses) and it can remove fdutimens (the Gnulib API,
which Emacs no longer uses).
Diffstat (limited to 'lisp/net')
| -rw-r--r-- | lisp/net/tramp-adb.el | 6 | ||||
| -rw-r--r-- | lisp/net/tramp-gvfs.el | 4 | ||||
| -rw-r--r-- | lisp/net/tramp-sh.el | 3 | ||||
| -rw-r--r-- | lisp/net/tramp-smb.el | 3 | ||||
| -rw-r--r-- | lisp/net/tramp-sudoedit.el | 3 |
5 files changed, 12 insertions, 7 deletions
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 2c9674fa36f..7ee740f93cb 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el | |||
| @@ -674,8 +674,9 @@ But handle the case, if the \"test\" command is not available." | |||
| 674 | (tramp-adb-send-command-and-check | 674 | (tramp-adb-send-command-and-check |
| 675 | v (format "chmod %o %s" mode localname))))) | 675 | v (format "chmod %o %s" mode localname))))) |
| 676 | 676 | ||
| 677 | (defun tramp-adb-handle-set-file-times (filename &optional time) | 677 | (defun tramp-adb-handle-set-file-times (filename &optional time flag) |
| 678 | "Like `set-file-times' for Tramp files." | 678 | "Like `set-file-times' for Tramp files." |
| 679 | flag ;; FIXME: Support 'nofollow'. | ||
| 679 | (with-parsed-tramp-file-name filename nil | 680 | (with-parsed-tramp-file-name filename nil |
| 680 | (tramp-flush-file-properties v localname) | 681 | (tramp-flush-file-properties v localname) |
| 681 | (let ((time (if (or (null time) | 682 | (let ((time (if (or (null time) |
| @@ -777,7 +778,8 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." | |||
| 777 | (set-file-times | 778 | (set-file-times |
| 778 | newname | 779 | newname |
| 779 | (tramp-compat-file-attribute-modification-time | 780 | (tramp-compat-file-attribute-modification-time |
| 780 | (file-attributes filename)))))) | 781 | (file-attributes filename)) |
| 782 | (unless ok-if-already-exists 'nofollow))))) | ||
| 781 | 783 | ||
| 782 | (defun tramp-adb-handle-rename-file | 784 | (defun tramp-adb-handle-rename-file |
| 783 | (filename newname &optional ok-if-already-exists) | 785 | (filename newname &optional ok-if-already-exists) |
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index 3ce7bbbd4a3..1ad57c59a5b 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el | |||
| @@ -1571,7 +1571,7 @@ If FILE-SYSTEM is non-nil, return file system attributes." | |||
| 1571 | (tramp-gvfs-url-file-name (tramp-make-tramp-file-name v)) | 1571 | (tramp-gvfs-url-file-name (tramp-make-tramp-file-name v)) |
| 1572 | "unix::mode" (number-to-string mode)))) | 1572 | "unix::mode" (number-to-string mode)))) |
| 1573 | 1573 | ||
| 1574 | (defun tramp-gvfs-handle-set-file-times (filename &optional time) | 1574 | (defun tramp-gvfs-handle-set-file-times (filename &optional time flag) |
| 1575 | "Like `set-file-times' for Tramp files." | 1575 | "Like `set-file-times' for Tramp files." |
| 1576 | (with-parsed-tramp-file-name filename nil | 1576 | (with-parsed-tramp-file-name filename nil |
| 1577 | (tramp-flush-file-properties v localname) | 1577 | (tramp-flush-file-properties v localname) |
| @@ -1582,7 +1582,7 @@ If FILE-SYSTEM is non-nil, return file system attributes." | |||
| 1582 | (current-time) | 1582 | (current-time) |
| 1583 | time))) | 1583 | time))) |
| 1584 | (tramp-gvfs-send-command | 1584 | (tramp-gvfs-send-command |
| 1585 | v "gvfs-set-attribute" "-t" "uint64" | 1585 | v "gvfs-set-attribute" (if flag "-nt" "-t") "uint64" |
| 1586 | (tramp-gvfs-url-file-name (tramp-make-tramp-file-name v)) | 1586 | (tramp-gvfs-url-file-name (tramp-make-tramp-file-name v)) |
| 1587 | "time::modified" (format-time-string "%s" time))))) | 1587 | "time::modified" (format-time-string "%s" time))))) |
| 1588 | 1588 | ||
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 84b8191bd3d..560941c4d5b 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -1495,11 +1495,12 @@ of." | |||
| 1495 | mode (tramp-shell-quote-argument localname)) | 1495 | mode (tramp-shell-quote-argument localname)) |
| 1496 | "Error while changing file's mode %s" filename)))) | 1496 | "Error while changing file's mode %s" filename)))) |
| 1497 | 1497 | ||
| 1498 | (defun tramp-sh-handle-set-file-times (filename &optional time) | 1498 | (defun tramp-sh-handle-set-file-times (filename &optional time flag) |
| 1499 | "Like `set-file-times' for Tramp files." | 1499 | "Like `set-file-times' for Tramp files." |
| 1500 | (with-parsed-tramp-file-name filename nil | 1500 | (with-parsed-tramp-file-name filename nil |
| 1501 | (when (tramp-get-remote-touch v) | 1501 | (when (tramp-get-remote-touch v) |
| 1502 | (tramp-flush-file-properties v localname) | 1502 | (tramp-flush-file-properties v localname) |
| 1503 | flag ;; FIXME: Support 'nofollow'. | ||
| 1503 | (let ((time | 1504 | (let ((time |
| 1504 | (if (or (null time) | 1505 | (if (or (null time) |
| 1505 | (tramp-compat-time-equal-p time tramp-time-doesnt-exist) | 1506 | (tramp-compat-time-equal-p time tramp-time-doesnt-exist) |
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index 42954cbda3d..d91362c879c 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el | |||
| @@ -619,7 +619,8 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." | |||
| 619 | (set-file-times | 619 | (set-file-times |
| 620 | newname | 620 | newname |
| 621 | (tramp-compat-file-attribute-modification-time | 621 | (tramp-compat-file-attribute-modification-time |
| 622 | (file-attributes filename)))))) | 622 | (file-attributes filename)) |
| 623 | (unless ok-if-already-exists 'nofollow))))) | ||
| 623 | 624 | ||
| 624 | (defun tramp-smb-handle-delete-directory (directory &optional recursive _trash) | 625 | (defun tramp-smb-handle-delete-directory (directory &optional recursive _trash) |
| 625 | "Like `delete-directory' for Tramp files." | 626 | "Like `delete-directory' for Tramp files." |
diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el index 7d8c8a90618..c054f405e3d 100644 --- a/lisp/net/tramp-sudoedit.el +++ b/lisp/net/tramp-sudoedit.el | |||
| @@ -523,10 +523,11 @@ the result will be a local, non-Tramp, file name." | |||
| 523 | (string-to-number (match-string 2))) | 523 | (string-to-number (match-string 2))) |
| 524 | (string-to-number (match-string 3))))))))) | 524 | (string-to-number (match-string 3))))))))) |
| 525 | 525 | ||
| 526 | (defun tramp-sudoedit-handle-set-file-times (filename &optional time) | 526 | (defun tramp-sudoedit-handle-set-file-times (filename &optional time flag) |
| 527 | "Like `set-file-times' for Tramp files." | 527 | "Like `set-file-times' for Tramp files." |
| 528 | (with-parsed-tramp-file-name filename nil | 528 | (with-parsed-tramp-file-name filename nil |
| 529 | (tramp-flush-file-properties v localname) | 529 | (tramp-flush-file-properties v localname) |
| 530 | flag ;; FIXME: Support 'nofollow'. | ||
| 530 | (let ((time | 531 | (let ((time |
| 531 | (if (or (null time) | 532 | (if (or (null time) |
| 532 | (tramp-compat-time-equal-p time tramp-time-doesnt-exist) | 533 | (tramp-compat-time-equal-p time tramp-time-doesnt-exist) |