branch: elpa/magit
commit ccf63ed63193109cbadc9df14d8d79823851aa7f
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
magit-find-file-noselect: Fix regression
This continues the fix in [1: fe0c43b6f5]. Visiting the actual file
needs the same handling as when we visit a blob; such relative paths
are also relative to the top-level, not `default-directory'.
Closes #5512.
1: 2026-01-16 fe0c43b6f5b3b20fce9ed30d203bf1267831b14f
magit-find-file-noselect: Fix regression
---
lisp/magit-files.el | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/lisp/magit-files.el b/lisp/magit-files.el
index ce1c9a78d0c..f80d2823782 100644
--- a/lisp/magit-files.el
+++ b/lisp/magit-files.el
@@ -111,6 +111,8 @@ be relative to the top directory of the repository.
Non-nil REVERT
means to revert the buffer. If `ask-revert', then only after asking.
A non-nil value for REVERT is ignored if REV is \"{worktree}\"."
(cond-let*
+ [[topdir (magit-toplevel)]
+ [file (expand-file-name file topdir)]]
((equal rev "{worktree}")
(let ((revert-without-query
(if (and$ (find-buffer-visiting file)
@@ -118,10 +120,9 @@ A non-nil value for REVERT is ignored if REV is
\"{worktree}\"."
(cons "." revert-without-query)
revert-without-query)))
(find-file-noselect file)))
- ([topdir (magit-toplevel)]
- [file (expand-file-name file topdir)]
+ ([_ topdir]
[defdir (file-name-directory file)]
- (setq rev (magit--abbrev-if-hash rev))
+ [rev (magit--abbrev-if-hash rev)]
(with-current-buffer (magit-get-revision-buffer-create
rev
(file-relative-name file topdir))