diff options
| author | Jonas Bernoulli <jonas@bernoul.li> | 2026-02-03 08:55:12 +0100 |
|---|---|---|
| committer | Jonas Bernoulli <jonas@bernoul.li> | 2026-02-03 08:55:12 +0100 |
| commit | a2165a0ba7ceae43fe67cd8023e866dec48382b9 (patch) | |
| tree | f3df5bbcb2073ba24bda9304e19ec25a2edd224f /lisp | |
| parent | f3a596a138f4948cd4acadaf6caaf08c400c157c (diff) | |
magit-find-file-noselect: Pivot to file if index has multiple stages
Diffstat (limited to 'lisp')
| -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 () |
