From 238b98bc4245783134b30cbb2918a95d19dacee6 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 1 May 2020 11:51:32 -0700 Subject: mailscripts.el: Add mailscripts-detach-head-from-existing-branch Signed-off-by: Sean Whitton --- debian/changelog | 1 + mailscripts.el | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index c530300..5624a7d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,7 @@ mailscripts (0.20-1) UNRELEASED; urgency=medium When the user inputs a branch name, it is used only to attempt the creation of a new branch, but the old prompt suggests that inputting an existing branch name would cause that branch to be checked out. + - Add mailscripts-detach-head-from-existing-branch defcustom. * Add mailing list info to CONTRIBUTING.md. -- Sean Whitton Fri, 27 Mar 2020 11:50:27 -0700 diff --git a/mailscripts.el b/mailscripts.el index 904a30a..6fc8c69 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -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. @@ -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 -- cgit v1.2.3