diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2022-12-21 10:30:03 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2022-12-21 10:30:13 -0700 |
commit | 7c84984d356f72f1a39d15def6b98fa6ad5b0f3c (patch) | |
tree | 956d1dd85d866a197c9bf916724b3d7e2345e241 /mailscripts.el | |
parent | 75fb37c19f0ec178b96e8801d632b1409114ba4e (diff) | |
download | mailscripts-7c84984d356f72f1a39d15def6b98fa6ad5b0f3c.tar.gz |
mailscripts.el: don't offer to detach a HEAD that's already detached
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
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" |