-(defun stgit-delete (patch-names)
- "Delete the named patches."
- (interactive (list (stgit-patches-marked-or-at-point)))
- (if (zerop (length patch-names))
- (error "No patches to delete")
- (when (yes-or-no-p (format "Really delete %d patches? "
- (length patch-names)))
- (stgit-capture-output nil
- (apply 'stgit-run "delete" patch-names))
- (stgit-reload))))
-
-(defun stgit-coalesce (patch-names)
- "Run stg coalesce on the named patches."
- (interactive (list (stgit-marked-patches)))
+(defun stgit-delete (patchsyms &optional spill-p)
+ "Delete the patches in PATCHSYMS.
+Interactively, delete the marked patches, or the patch at point.
+
+With a prefix argument, or SPILL-P, spill the patch contents to
+the work tree and index."
+ (interactive (list (stgit-patches-marked-or-at-point)
+ current-prefix-arg))
+ (unless patchsyms
+ (error "No patches to delete"))
+ (let ((npatches (length patchsyms)))
+ (when (yes-or-no-p (format "Really delete %d patch%s%s? "
+ npatches
+ (if (= 1 npatches) "" "es")
+ (if spill-p
+ " (spilling contents to index)"
+ "")))
+ (let ((args (if spill-p
+ (cons "--spill" patchsyms)
+ patchsyms)))
+ (stgit-capture-output nil
+ (apply 'stgit-run "delete" args))
+ (stgit-reload)))))
+
+(defun stgit-coalesce (patchsyms)
+ "Coalesce the patches in PATCHSYMS.
+Interactively, coalesce the marked patches."
+ (interactive (list stgit-marked-patches))
+ (when (< (length patchsyms) 2)
+ (error "Need at least two patches to coalesce"))