branch: elpa/magit
commit 0ea29a615a33743e08a457402a4cbea37a4a4a88
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
magit-discard: Refresh after discarding all untracked files
---
CHANGELOG | 2 ++
lisp/magit-apply.el | 12 ++++++++----
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 286bfcf9aa5..7ca944d60c6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,8 @@ Bugfixes:
that to immediately be displayed at the top of windows displaying
log buffers. #5403
+- Refreshing was skipped after discarding all untracked files.
+
* v4.3.7 2025-07-01
- Refreshing a buffer causes its content to be recreated, which can
diff --git a/lisp/magit-apply.el b/lisp/magit-apply.el
index fcf119f2cb4..7584e89c492 100644
--- a/lisp/magit-apply.el
+++ b/lisp/magit-apply.el
@@ -490,10 +490,7 @@ of a side, then keep that side without prompting."
(pcase (list (magit-diff-type) (magit-diff-scope))
(`(committed ,_) (user-error "Cannot discard committed changes"))
(`(undefined ,_) (user-error "Cannot discard this change"))
- (`(untracked list) (magit-discard-files--delete
- (magit-with-toplevel
- (magit-untracked-files nil nil "--directory"))
- nil))
+ (`(untracked list) (magit-discard-untracked))
(`(,_ region) (magit-discard-region s))
(`(,_ hunk) (magit-discard-hunk s))
(`(,_ hunks) (magit-discard-hunks s))
@@ -501,6 +498,13 @@ of a side, then keep that side without prompting."
(`(,_ files) (magit-discard-files s))
(`(,_ list) (magit-discard-files s)))))
+(defun magit-discard-untracked ()
+ (magit-discard-files--delete
+ (magit-with-toplevel
+ (magit-untracked-files nil nil "--directory"))
+ nil)
+ (magit-refresh))
+
(defun magit-discard-region (section)
(magit-confirm 'discard "Discard region")
(magit-discard-apply section 'magit-apply-region))