diff options
-rw-r--r-- | lisp/init-git.el | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lisp/init-git.el b/lisp/init-git.el index 2b4cbfb..2c1b145 100644 --- a/lisp/init-git.el +++ b/lisp/init-git.el @@ -264,12 +264,12 @@ By default, the path for the file name is relative to the top directory of the repository. Remove the directory component from the file name if NO-DIRECTORY is non-nil." (interactive "P") - (let* ((default-directory (magit-toplevel)) - (files (magit-staged-files)) + (unless (magit-toplevel) + (user-error "Not in git repo")) + (let* ((files (magit-staged-files)) (file (if (= 1 (length files)) (car files) - (completing-read "Staged file: " (magit-staged-files) - nil t)))) + (completing-read "Staged file: " files nil t)))) (insert (if no-directory (file-name-nondirectory file) file)))) (define-key ctl-x-4-map "g" 'magit-find-file-other-window) |