branch: elpa/magit
commit 365027db8fa307140087b43bb7f5f62751e78100
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
magit-stash--apply-1: New function
Purely for cosmetic reasons (reduce indentation and nesting).
Eventually we'll stop supporting Git v2.38.0 and older.
---
lisp/magit-stash.el | 48 ++++++++++++++++++++++++++----------------------
1 file changed, 26 insertions(+), 22 deletions(-)
diff --git a/lisp/magit-stash.el b/lisp/magit-stash.el
index d363fabc99b..c4fe13d8cba 100644
--- a/lisp/magit-stash.el
+++ b/lisp/magit-stash.el
@@ -317,30 +317,34 @@ the user whether to use \"--3way\" or \"--reject\"."
(defun magit-stash--apply (action stash)
(if (magit-git-version< "2.38.0")
(magit-run-git "stash" action stash (and current-prefix-arg "--index"))
- (or (magit--run-git-stash action "--index" stash)
- ;; The stash's index could not be applied, so always keep the stash.
- (magit--run-git-stash "apply" stash)
- (let* ((range (format "%s^..%s" stash stash))
- (stashed (magit-git-items "diff" "-z" "--name-only" range "--"))
- (conflicts (cl-sort (cl-union (magit-unstaged-files t stashed)
- (magit-untracked-files t stashed)
- :test #'equal)
- #'string<))
- (arg (cond
- ((not conflicts) "--3way")
- ((magit-confirm-files
- 'stash-apply-3way conflicts
- "Apply stash using `--3way', which requires first
staging"
- "(else use `--reject')"
- t)
- (magit-stage-1 nil conflicts)
- "--3way")
- ("--reject"))))
- (with-temp-buffer
- (magit-git-insert "diff" range)
- (magit-run-git-with-input "apply" arg "-"))))
+ (magit-stash--apply-1 action stash)
(magit-refresh)))
+(defun magit-stash--apply-1 (action stash)
+ (or
+ (magit--run-git-stash action "--index" stash)
+ ;; The stash's index could not be applied, so always keep the stash.
+ (magit--run-git-stash "apply" stash)
+ (let* ((range (format "%s^..%s" stash stash))
+ (stashed (magit-git-items "diff" "-z" "--name-only" range "--"))
+ (conflicts (cl-sort (cl-union (magit-unstaged-files t stashed)
+ (magit-untracked-files t stashed)
+ :test #'equal)
+ #'string<))
+ (arg (cond
+ ((not conflicts) "--3way")
+ ((magit-confirm-files
+ 'stash-apply-3way conflicts
+ "Apply stash using `--3way', which requires first staging"
+ "(else use `--reject')"
+ t)
+ (magit-stage-1 nil conflicts)
+ "--3way")
+ ("--reject"))))
+ (with-temp-buffer
+ (magit-git-insert "diff" range)
+ (magit-run-git-with-input "apply" arg "-")))))
+
(defun magit--run-git-stash (&rest args)
(magit--with-temp-process-buffer
(let ((exit (save-excursion