[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/git-commit f6f4b96b64 2/2: magit-stash-{apply, pop}: Ignor
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/git-commit f6f4b96b64 2/2: magit-stash-{apply, pop}: Ignore unrelated files to preserve index |
Date: |
Sun, 23 Jul 2023 15:59:33 -0400 (EDT) |
branch: elpa/git-commit
commit f6f4b96b641a5af75e90b5431a32369ab0f664a7
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
magit-stash-{apply,pop}: Ignore unrelated files to preserve index
The stash index cannot preserved when the stashed files are
also modified in the working tree, but other modified files
do not prevent that, so ignore those.
---
lisp/magit-git.el | 3 +++
lisp/magit-stash.el | 6 ++++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index ae5ba5be62..c35394b531 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -1118,6 +1118,9 @@ tracked file."
(magit-git-items "ls-files" "-z" "--others" "--ignored"
"--exclude-standard" "--directory"))
+(defun magit-stashed-files (stash)
+ (apply #'magit-git-items "stash" "show" "-z" "--name-only" stash))
+
(defun magit-skip-worktree-files ()
(--keep (and (= (aref it 0) ?S)
(substring it 2))
diff --git a/lisp/magit-stash.el b/lisp/magit-stash.el
index 4e202025ea..8c9e9611eb 100644
--- a/lisp/magit-stash.el
+++ b/lisp/magit-stash.el
@@ -241,7 +241,8 @@ If nothing is staged, then try to reinstate the stashed
index.
Doing so is not possible if there are staged changes."
(interactive (list (magit-read-stash "Apply stash")))
(magit-run-git "stash" "apply" stash
- (and (not (magit-anything-staged-p))
+ (and (not (apply #'magit-anything-staged-p nil
+ (magit-stashed-files stash)))
"--index")))
;;;###autoload
@@ -252,7 +253,8 @@ Doing so is not possible if there are staged changes. Do
not
remove the stash, if it cannot be applied."
(interactive (list (magit-read-stash "Pop stash")))
(magit-run-git "stash" "apply" stash
- (and (not (magit-anything-staged-p))
+ (and (not (apply #'magit-anything-staged-p nil
+ (magit-stashed-files stash)))
"--index")))
;;;###autoload