org-babel-load-file: Do not rely on `org-babel-tangle-file' making changes

* lisp/org.el (org-babel-load-file): Update modification time even
when `org-babel-tangle-file' does not actually modify the tangled
file.  This makes sure that modify-time comparison logic does not make
Org re-tangle Org file that had been changed but the changes did not
affect the tangled code.

See https://orgmode.org/list/t5j75h$dbo$1@ciao.gmane.io
This commit is contained in:
Ihor Radchenko 2022-05-13 18:21:36 +08:00
parent f6f26d4ce4
commit 1525a5a64e
No known key found for this signature in database
GPG key ID: 6470762A7DA11D8B

View file

@ -256,6 +256,12 @@ byte-compiled before it is loaded."
tangled-file
(file-attribute-modification-time
(file-attributes (file-truename file))))
;; Make sure that tangled file modification time is
;; updated even when `org-babel-tangle-file' does not make changes.
;; This avoids re-tangling changed FILE where the changes did
;; not affect the tangled code.
(when (file-exists-p tangled-file)
(set-file-times tangled-file))
(org-babel-tangle-file file
tangled-file
(rx string-start