diff options
Diffstat (limited to 'mailscripts.el')
-rw-r--r-- | mailscripts.el | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/mailscripts.el b/mailscripts.el index 610e337..a7a8240 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -395,9 +395,13 @@ See also the interactive wrapper command `mailscripts-prepare-patch'." (defun mailscripts--check-out-branch (branch) (if (string= branch "") - (when (or (eq mailscripts-detach-head-from-existing-branch t) - (and (eq mailscripts-detach-head-from-existing-branch 'ask) - (yes-or-no-p "Detach HEAD before applying patches?"))) + (when (and + ;; Don't proceed if HEAD is already detached. + (zerop (call-process "git" nil nil nil + "symbolic-ref" "--quiet" "HEAD")) + (or (eq mailscripts-detach-head-from-existing-branch t) + (and (eq mailscripts-detach-head-from-existing-branch 'ask) + (yes-or-no-p "Detach HEAD before applying patches?")))) (call-process-shell-command "git checkout --detach")) (call-process-shell-command (format "git checkout -b %s" |