aboutsummaryrefslogtreecommitdiff
path: root/lisp/magit-commit.el
diff options
context:
space:
mode:
authorJonas Bernoulli <jonas@bernoul.li>2022-04-24 15:02:08 +0200
committerJonas Bernoulli <jonas@bernoul.li>2022-04-24 15:02:08 +0200
commit4eed9e1a452751ae39d368fcc826dfdb93a8e8a1 (patch)
treec24a7334a23211599cba81f0fa84df7860508541 /lisp/magit-commit.el
parentb4d54d3f8ee047479980b6d8079f3ce1a93bb6a4 (diff)
magit-openpgp-default-signing-key: New option
Diffstat (limited to 'lisp/magit-commit.el')
-rw-r--r--lisp/magit-commit.el22
1 files changed, 18 insertions, 4 deletions
diff --git a/lisp/magit-commit.el b/lisp/magit-commit.el
index 6755d91..f28766a 100644
--- a/lisp/magit-commit.el
+++ b/lisp/magit-commit.el
@@ -116,6 +116,16 @@ Also see https://github.com/magit/magit/issues/4132."
:group 'magit-commands
:type 'boolean)
+(defcustom magit-openpgp-default-signing-key nil
+ "Fingerprint of your default Openpgp key used for signing.
+If the specified primary key has signing capacity then it is used
+as the value of the `--gpg-sign' argument without prompting, even
+when other such keys exist. To be able to select another key you
+must then use a prefix argument."
+ :package-version '(magit . "3.4.0")
+ :group 'magit-commands
+ :type 'string)
+
(defvar magit-post-commit-hook-commands
'(magit-commit-extend
magit-commit-fixup
@@ -176,7 +186,7 @@ Also see https://github.com/magit/magit/issues/4132."
(defvar magit-gpg-secret-key-hist nil)
(defun magit-read-gpg-secret-key
- (prompt &optional initial-input history predicate)
+ (prompt &optional initial-input history predicate default)
(require 'epa)
(let* ((keys (cl-mapcan
(lambda (cert)
@@ -198,8 +208,11 @@ Also see https://github.com/magit/magit/issues/4132."
(propertize id 'face 'highlight)
" " author))))))
(epg-list-keys (epg-make-context epa-protocol) nil t)))
- (choice (completing-read prompt keys nil nil nil
- history nil initial-input)))
+ (choice (or (and (not current-prefix-arg)
+ (or (and (length= keys 1) (car keys))
+ (and default (car (member default keys)))))
+ (completing-read prompt keys nil nil nil
+ history nil initial-input))))
(set-text-properties 0 (length choice) nil choice)
choice))
@@ -209,7 +222,8 @@ Also see https://github.com/magit/magit/issues/4132."
(lambda (cert)
(cl-some (lambda (key)
(memq 'sign (epg-sub-key-capability key)))
- (epg-key-sub-key-list cert)))))
+ (epg-key-sub-key-list cert)))
+ magit-openpgp-default-signing-key))
(transient-define-argument magit-commit:--reuse-message ()
:description "Reuse commit message"