diff options
| author | Kyle Meyer <kyle@kyleam.com> | 2026-03-13 00:52:27 -0400 |
|---|---|---|
| committer | Kyle Meyer <kyle@kyleam.com> | 2026-03-13 00:52:27 -0400 |
| commit | 9c76756df161a4bfc91aff64cbe01599835d5a35 (patch) | |
| tree | 9795a6babf6e7dfe5fad2d02c465bf3350c4cbc7 /lisp/magit-git.el | |
| parent | caeefe6b816c913358651d0d6d118e684a017eb8 (diff) | |
magit-find-file-noselect: Fix finding blobs over TRAMP
magit-find-file-noselect inserts blob contents via
magit--refresh-blob-buffer. As of f55bfaf79 (Set new magit-blob-oid
in blob buffers and only refresh if necessary, 2026-02-03),
magit--refresh-blob-buffer inserts the blob contents only if the value
returned by magit-blob-oid is different from what's stored in
magit-buffer-blob-oid (unless optional FORCE argument is non-nil).
Over TRAMP, magit-blob-oid returns nil because the file name with a
remote identifier is passed to ls-tree and ls-files. This nil value
is the same as the initial magit-buffer-blob-oid value, leading to
commands like magit-ediff-stage and magit-diff-visit-file generating
empty buffers for blobs.
Update magit-blob-oid and magit--file-index-stages to call
magit-convert-filename-for-git so that the local file name is passed
to ls-tree/ls-files.
Fixes #5529.
Diffstat (limited to 'lisp/magit-git.el')
| -rw-r--r-- | lisp/magit-git.el | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lisp/magit-git.el b/lisp/magit-git.el index 2c29cd3..439bf09 100644 --- a/lisp/magit-git.el +++ b/lisp/magit-git.el @@ -1332,11 +1332,13 @@ Sorted from longest to shortest CYGWIN name." (defun magit-blob-oid (rev file) (if (equal rev "{index}") (cadr (car (magit--file-index-stages file))) - (magit-git-string "ls-tree" "--object-only" rev "--" file))) + (magit-git-string "ls-tree" "--object-only" rev "--" + (magit-convert-filename-for-git file)))) (defun magit--file-index-stages (file) (mapcar (##split-string % " ") - (magit-git-lines "ls-files" "--stage" "--" file))) + (magit-git-lines "ls-files" "--stage" "--" + (magit-convert-filename-for-git file)))) (defun magit--insert-blob-contents (rev file) (let ((coding-system-for-read (or coding-system-for-read 'undecided))) |
