diff options
Diffstat (limited to 'mailscripts.el')
-rw-r--r-- | mailscripts.el | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/mailscripts.el b/mailscripts.el index 0658c76..2280f5a 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -1,7 +1,7 @@ ;;; mailscripts.el --- functions to access tools in the mailscripts package ;; Author: Sean Whitton <spwhitton@spwhitton.name> -;; Version: 0.18 +;; Version: 0.20 ;; Package-Requires: (notmuch projectile) ;; Copyright (C) 2018, 2019 Sean Whitton @@ -34,6 +34,17 @@ E.g. `email/'." :type 'string :group 'mailscripts) +(defcustom mailscripts-detach-head-from-existing-branch nil + "Whether to detach HEAD before applying patches to an existing branch. + +This is useful if you want to manually review the result of +applying patches before updating any of your existing branches, +or for quick, ad hoc testing of a patch series. + +Note that this does not prevent the creation of new branches." + :type 'boolean + :group 'mailscripts) + ;;;###autoload (defun notmuch-slurp-debbug (bug &optional no-open) "Slurp Debian bug with bug number BUG and open the thread in notmuch. @@ -67,7 +78,7 @@ See notmuch-extract-patch(1) manpage for limitations: in particular, this Emacs Lisp function supports passing only entire threads to the notmuch-extract-patch(1) command." (interactive - "Dgit repo: \nsbranch name (or leave blank to apply to current HEAD): \nP") + "Dgit repo: \nsnew branch name (or leave blank to apply to current HEAD): \nP") (let ((thread-id ;; If `notmuch-show' was called with a notmuch query rather ;; than a thread ID, as `org-notmuch-follow-link' in @@ -109,18 +120,18 @@ Patches are applied using git-am(1), so we only consider attachments with filenames which look like they were generated by git-format-patch(1)." (interactive - "Dgit repo: \nsbranch name (or leave blank to apply to current HEAD): ") + "Dgit repo: \nsnew branch name (or leave blank to apply to current HEAD): ") (with-current-notmuch-show-message (let ((default-directory (expand-file-name repo)) - (mm-handle (mm-dissect-buffer))) + (mm-handle (mm-dissect-buffer t))) (mailscripts--check-out-branch branch) (notmuch-foreach-mime-part (lambda (p) (let* ((disposition (mm-handle-disposition p)) (filename (cdr (assq 'filename disposition)))) (and filename - (string-match - "^\\(v[0-9]+-\\)?[0-9]+-.+\.\\(patch\\|diff\\|txt\\)$" filename) + (string-match "^\\(v?[0-9]+\\)-.+\\.\\(patch\\|diff\\|txt\\)$" + filename) (mm-pipe-part p "git am")))) mm-handle)))) @@ -131,7 +142,9 @@ git-format-patch(1)." (mailscripts--projectile-repo-and-branch 'notmuch-extract-message-patches)) (defun mailscripts--check-out-branch (branch) - (unless (string= branch "") + (if (string= branch "") + (when mailscripts-detach-head-from-existing-branch + (call-process-shell-command "git checkout --detach")) (call-process-shell-command (format "git checkout -b %s" (shell-quote-argument |