Commit 82fedebd authored by Jonas Bernoulli's avatar Jonas Bernoulli

magit-stash-{*}: use magit-dwim-selection

Instead of hard-coding whether these commands use the stash at point
without requiring confirmation and offering other choices, remove
`magit-read-stash's USE-AT-POINT argument (which was used for that
purpose) and instead add equivalent entries to `magit-dwim-selection'.
parent 99b8328b
......@@ -1673,12 +1673,11 @@ Return a list of two integers: (A>B B>A)."
require-match nil 'magit-revision-history
(magit-tag-at-point)))
(defun magit-read-stash (prompt &optional use-at-point)
(let ((atpoint (magit-stash-at-point)))
(or (and use-at-point atpoint)
(let ((stashes (magit-list-stashes)))
(magit-completing-read prompt stashes nil t nil nil
(or atpoint (car stashes)))))))
(defun magit-read-stash (prompt)
(let ((stashes (magit-list-stashes)))
(magit-completing-read prompt stashes nil t nil nil
(magit-stash-at-point)
(car stashes))))
(defun magit-read-remote (prompt &optional default use-only)
(let ((remotes (magit-list-remotes)))
......
......@@ -198,7 +198,7 @@ while two prefix arguments are equivalent to `--all'."
"Apply a stash to the working tree.
Try to preserve the stash index. If that fails because there
are staged changes, apply without preserving the stash index."
(interactive (list (magit-read-stash "Apply stash" t)))
(interactive (list (magit-read-stash "Apply stash")))
(if (= (magit-call-git "stash" "apply" "--index" stash) 0)
(magit-refresh)
(magit-run-git "stash" "apply" stash)))
......@@ -208,7 +208,7 @@ are staged changes, apply without preserving the stash index."
Try to preserve the stash index. If that fails because there
are staged changes, apply without preserving the stash index
and forgo removing the stash."
(interactive (list (magit-read-stash "Pop stash" t)))
(interactive (list (magit-read-stash "Pop stash")))
(if (= (magit-call-git "stash" "apply" "--index" stash) 0)
(magit-stash-drop stash)
(magit-run-git "stash" "apply" stash)))
......@@ -250,7 +250,7 @@ When the region is active offer to drop all contained stashes."
;;;###autoload
(defun magit-stash-branch (stash branch)
"Create and checkout a new BRANCH from STASH."
(interactive (list (magit-read-stash "Branch stash" t)
(interactive (list (magit-read-stash "Branch stash")
(magit-read-string-ns "Branch name")))
(magit-run-git "stash" "branch" branch stash))
......@@ -259,7 +259,7 @@ When the region is active offer to drop all contained stashes."
"Create and checkout a new BRANCH and apply STASH.
The branch is created using `magit-branch', using the current
branch or `HEAD' as the string-point."
(interactive (list (magit-read-stash "Branch stash" t)
(interactive (list (magit-read-stash "Branch stash")
(magit-read-string-ns "Branch name")))
(let ((inhibit-magit-refresh t))
(magit-branch branch (or (magit-get-current-branch) "HEAD")))
......@@ -268,7 +268,7 @@ branch or `HEAD' as the string-point."
;;;###autoload
(defun magit-stash-format-patch (stash)
"Create a patch from STASH"
(interactive (list (magit-read-stash "Create patch from stash" t)))
(interactive (list (magit-read-stash "Create patch from stash")))
(with-temp-file (magit-rev-format "0001-%f.patch" stash)
(magit-git-insert "stash" "show" "-p" stash))
(magit-refresh))
......
......@@ -92,7 +92,13 @@ Only the following commands support this option:
`magit-branch-rename'
`magit-tag'")
(defcustom magit-dwim-selection nil
(defcustom magit-dwim-selection
'((magit-stash-apply nil t)
(magit-stash-branch nil t)
(magit-stash-branch-here nil t)
(magit-stash-format-patch nil t)
(magit-stash-drop nil nil)
(magit-stash-pop nil t))
"When not to offer alternatives and ask for confirmation.
Many commands by default ask the user to select from a list of
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment