branch: elpa/magit commit d5e0f3a6391f38fc5bd6df875ce58c85805276ed Author: Jonas Bernoulli <jo...@bernoul.li> Commit: Jonas Bernoulli <jo...@bernoul.li>
magit-wip-purge: New command --- lisp/magit-wip.el | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lisp/magit-wip.el b/lisp/magit-wip.el index 3a6c32bad1..712b784527 100644 --- a/lisp/magit-wip.el +++ b/lisp/magit-wip.el @@ -435,6 +435,27 @@ many \"branches\" of each wip ref are shown." (cl-decf count)) (cons wipref (nreverse tips))))) +(defun magit-wip-purge () + "Ask to delete all wip-refs that no longer have a corresponding ref." + (interactive) + (if-let ((wiprefs (thread-last + (cl-set-difference (magit-list-refs "refs/wip/") + (magit-list-refs) + :test (##equal (substring %1 15) %2)) + (delete "refs/wip/index/HEAD") + (delete "refs/wip/wtree/HEAD")))) + (progn + (magit-confirm 'purge-dangling-wiprefs + "Delete wip-ref %s without corresponding ref" + "Delete %d wip-refs without corresponding ref" + nil wiprefs) + (message "Deleting wip-refs...") + (dolist (wipref wiprefs) + (magit-call-git "update-ref" "-d" wipref)) + (message "Deleting wip-refs...done") + (magit-refresh)) + (message "All wip-refs have a corresponding ref"))) + ;;; _ (provide 'magit-wip) ;;; magit-wip.el ends here