From 736064843a60ac1814da71550ae04c9673ed1e89 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 6 Nov 2019 20:34:53 -0700 Subject: mailscripts.el: if user does not enter a branch name, use HEAD Signed-off-by: Sean Whitton --- debian/changelog | 1 + mailscripts.el | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/debian/changelog b/debian/changelog index dc13036..919eb1a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,7 @@ mailscripts (0.12-1) UNRELEASED; urgency=medium Thanks to Daniel Kahn Gillmor for the patch series. * mailscripts.el: add mailscripts-extract-patches-branch-prefix defcustom. * mailscripts.el: add notmuch-extract-thread-patches-projectile command. + * mailscripts.el: if user does not enter a branch name, use current HEAD. * mailscripts.el: add notmuch-extract-message-patches{,-projectile} commands. * elpa-mailscripts now depends on elpa-projectile. diff --git a/mailscripts.el b/mailscripts.el index 6bc64bc..db1cf94 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -65,7 +65,8 @@ The target branch may or may not already exist. 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: \nsnew branch name: \nP") + (interactive + "Dgit repo: \nsbranch name (or leave blank to apply to current HEAD): \nP") (let ((thread-id notmuch-show-thread-id) (default-directory (expand-file-name repo))) (mailscripts--check-out-branch branch no-prefix) @@ -93,7 +94,8 @@ The target branch may or may not already exist. 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: \nsnew branch name: \nP") + (interactive + "Dgit repo: \nsbranch name (or leave blank to apply to current HEAD): \nP") (with-current-notmuch-show-message (let ((default-directory (expand-file-name repo)) (mm-handle (mm-dissect-buffer))) @@ -116,17 +118,20 @@ git-format-patch(1)." 'notmuch-extract-message-patches no-prefix)) (defun mailscripts--check-out-branch (branch no-prefix) - (call-process-shell-command - (format "git checkout -b %s" - (shell-quote-argument - (if (and (not no-prefix) mailscripts-extract-patches-branch-prefix) - (concat mailscripts-extract-patches-branch-prefix branch) - branch))))) + (unless (string= branch "") + (call-process-shell-command + (format "git checkout -b %s" + (shell-quote-argument + (if (and (not no-prefix) mailscripts-extract-patches-branch-prefix) + (concat mailscripts-extract-patches-branch-prefix branch) + branch)))))) (defun mailscripts--projectile-repo-and-branch (f &optional no-prefix) (let ((repo (projectile-completing-read "Select projectile project: " projectile-known-projects)) - (branch (completing-read "Branch name: " nil))) + (branch (completing-read + "Branch name (or leave blank to apply to current HEAD): " + nil))) (funcall f repo branch no-prefix))) (provide 'mailscripts) -- cgit v1.2.3