diff options
| -rw-r--r-- | lisp/magit-blame.el | 2 | ||||
| -rw-r--r-- | lisp/magit-extras.el | 2 | ||||
| -rw-r--r-- | lisp/magit-git.el | 11 | ||||
| -rw-r--r-- | lisp/magit.el | 3 |
4 files changed, 12 insertions, 6 deletions
diff --git a/lisp/magit-blame.el b/lisp/magit-blame.el index 30f6f15..c188aaf 100644 --- a/lisp/magit-blame.el +++ b/lisp/magit-blame.el @@ -214,7 +214,7 @@ only arguments available from `magit-blame-popup' should be used. (list it (magit-blame-chunk-get :previous-file) args (magit-blame-chunk-get :previous-start)) (user-error "Block has no further history")) - (--if-let (magit-file-relative-name) + (--if-let (magit-file-relative-name nil 'tracked) (list (or magit-buffer-refname magit-buffer-revision) it args) (if buffer-file-name (user-error "Buffer isn't visiting a tracked file") diff --git a/lisp/magit-extras.el b/lisp/magit-extras.el index 28faa7d..cb79f6b 100644 --- a/lisp/magit-extras.el +++ b/lisp/magit-extras.el @@ -61,7 +61,7 @@ blame to center around the line point is on." (let (revision filename) (when (or current-prefix-arg (not (setq revision "HEAD" - filename (magit-file-relative-name)))) + filename (magit-file-relative-name nil 'tracked)))) (setq revision (magit-read-branch-or-commit "Blame from revision") filename (magit-read-file-from-rev revision "Blame file"))) (list revision filename diff --git a/lisp/magit-git.el b/lisp/magit-git.el index 4f49446..6133c97 100644 --- a/lisp/magit-git.el +++ b/lisp/magit-git.el @@ -361,16 +361,21 @@ a bare repositories." (put 'magit-buffer-refname 'permanent-local t) (put 'magit-buffer-file-name 'permanent-local t) -(defun magit-file-relative-name (&optional file) +(defun magit-file-relative-name (&optional file tracked) "Return the path of FILE relative to the repository root. + If optional FILE is nil or omitted return the relative path of the file being visited in the current buffer, if any, else nil. -If the file is not inside a Git repository then return nil." +If the file is not inside a Git repository then return nil. + +If TRACKED is non-nil, return the path only if it matches a +tracked file." (unless file (with-current-buffer (or (buffer-base-buffer) (current-buffer)) (setq file (or magit-buffer-file-name buffer-file-name)))) - (when file + (when (and file (or (not tracked) + (magit-file-tracked-p file))) (--when-let (magit-toplevel file) (file-relative-name file it)))) diff --git a/lisp/magit.el b/lisp/magit.el index 006b632..f5747e3 100644 --- a/lisp/magit.el +++ b/lisp/magit.el @@ -1574,7 +1574,8 @@ If FILE isn't tracked in Git fallback to using `delete-file'." (unless tracked-only (magit-untracked-files))))) (magit-completing-read prompt choices nil t nil nil (car (member (or (magit-section-when (file)) - (magit-file-relative-name)) + (magit-file-relative-name + nil tracked-only)) choices))))) (defun magit-read-files (prompt initial-contents) |
