diff options
authorSean Whitton <>2020-05-01 11:51:32 -0700
committerSean Whitton <>2020-05-01 12:04:04 -0700
commit238b98bc4245783134b30cbb2918a95d19dacee6 (patch)
parentf343a4e23e11ae97e6354ca9c4f91a60a0ea6563 (diff)
mailscripts.el: Add mailscripts-detach-head-from-existing-branch
Signed-off-by: Sean Whitton <>
2 files changed, 15 insertions, 1 deletions
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
-- 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)
(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"))
(format "git checkout -b %s"