branch: elpa/magit
commit c1def9b47e64a6111dde9eb6d835c477b71ec429
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
magit-find-file-noselect: Avoid misleading error message
Until the previous commit, using nil as REV would have resulted in
an error "FILE is not inside a Git repository", regardless of whether
that was actually true or not. Add a fall-through "Unexpected error"
in case some other unexpected issue manifests itself.
---
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 3a4dc2e08f..beae1edf4a 100644
--- a/lisp/magit-files.el
+++ b/lisp/magit-files.el
@@ -105,8 +105,9 @@ REV is a revision or one of \"{worktree}\" or \"{index}\"."
(cons "." revert-without-query)
revert-without-query)))
(find-file-noselect file)))
- ([_ topdir]
- [defdir (file-name-directory file)]
+ ((not topdir)
+ (error "%s is not inside a Git repository" file))
+ ([defdir (file-name-directory file)]
[rev (magit--abbrev-if-hash rev)]
(unless (file-in-directory-p file topdir)
(error "%s is not inside Git repository %s" file topdir))
@@ -119,7 +120,7 @@ REV is a revision or one of \"{worktree}\" or \"{index}\"."
(setq-local revert-buffer-function #'magit--revert-blob-buffer)
(magit--refresh-blob-buffer)
(current-buffer)))
- ((error "%s is not inside a Git repository" file)))))
+ ((error "Unexpected error")))))
(when (and (not no-restore-position)
(equal (magit-file-relative-name) file-relative))
(let ((pos (magit-find-file--position)))