diff options
| -rw-r--r-- | lisp/magit-files.el | 3 | ||||
| -rw-r--r-- | lisp/magit-git.el | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/lisp/magit-files.el b/lisp/magit-files.el index 73541d7..a590cae 100644 --- a/lisp/magit-files.el +++ b/lisp/magit-files.el @@ -115,6 +115,9 @@ the line and column corresponding to that location." REV is a revision or one of \"{worktree}\" or \"{index}\". 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}\"." + (when (and (equal rev "{index}") + (length> (magit--file-index-stages file) t)) + (setq rev "{worktree}")) (cond-let* [[topdir (magit-toplevel)] [file (expand-file-name file topdir)]] diff --git a/lisp/magit-git.el b/lisp/magit-git.el index 414ca02..960a4f9 100644 --- a/lisp/magit-git.el +++ b/lisp/magit-git.el @@ -1329,6 +1329,12 @@ Sorted from longest to shortest CYGWIN name." (and (derived-mode-p 'magit-log-mode) (car magit-buffer-log-files)))) +;;; Blobs + +(defun magit--file-index-stages (file) + (mapcar (##split-string % " ") + (magit-git-lines "ls-files" "--stage" "--" file))) + ;;; Predicates (defun magit-no-commit-p () |
