Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use sign using gpg (--gpg-sign=) had problem #1349

Closed
Superbil opened this issue Apr 22, 2014 · 17 comments
Closed

Use sign using gpg (--gpg-sign=) had problem #1349

Superbil opened this issue Apr 22, 2014 · 17 comments
Labels
support User needs some help
Milestone

Comments

@Superbil
Copy link

I use magit-key-mode-popup-committing to popup commit menu, then use =S to chose my gpg-key.

After that, I got somethings wrong like this (from Message)

Wrong type argument: stringp, ("Kai-Yuan Cheng (superbil) <superbil@gmail.com>")
maphash: Wrong type argument: characterp, "Kai-Yuan Cheng (superbil) <superbil@gmail.com>" [3 times]

committing menu is not working again, It is broken.

my gpg key like this

pub   4096R/206AFB69 2012-12-09
uid       [ultimate] Cheng, Kai-Yuan (鄭開元) <superbil@gmail.com>
uid       [ultimate] Kai-Yuan Cheng (superbil) <superbil@gmail.com>
sub   4096R/2E470972 2013-08-07 [expires: 2015-08-07]
@afrepues
Copy link
Contributor

Can you please specify what version of Magit and Emacs are you running and on what OS?

@Superbil
Copy link
Author

magit-version: magit-20140416.1539
emacs-version: GNU Emacs 24.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.36) of 2013-03-13 on bob.porkrind.org

Is need the other message of debug ?

@afrepues
Copy link
Contributor

Does the error happen right after you chose the GPG key, when you press c, after saving the commit message, or at some other point?

@Superbil
Copy link
Author

@afrepues The error was happen right after I chosed the GPG key, than that buffer is crash.

@tarsius tarsius added this to the support/later/needinfo/... milestone May 2, 2014
@tarsius
Copy link
Member

tarsius commented May 5, 2014

I cannot reproduce this with either the master or next branch. I don't think I have changed anything here during the last few weeks but to be sure please update to the latest version from Melpa.

If the problem persists, then please do M-x toggle-debug-on-error, try again to make a signed commit, and post the backtrace here.

@Superbil
Copy link
Author

Superbil commented May 6, 2014

I use last version on Melpa, magit-20140505.301 try again.

Debugger entered--Lisp error: (wrong-type-argument stringp ("Kai-Yuan Cheng (superbil) <superbil@gmail.com>"))
  propertize(("Kai-Yuan Cheng (superbil) <superbil@gmail.com>") face magit-key-mode-args-face)
  #[(x) "\302\303\304�8\305\306\304�8   \307#\310\311##\207" [x magit-key-mode-current-args format "(%s) %s" 2 propertize gethash "" face magit-key-mode-args-face] 8](("=S" "Sign using gpg" "--gpg-sign=" magit-read-gpg-secret-key))
  #[(x) "\306�@\307\310#��A@��\205����!�\311\312    \n\f\203��\313\202 �\314\f\206%�\314%�\306
\315�@#,\207" [x head desc maker more text propertize face magit-key-mode-button-face format " %s: %s%s%s" " " "" key-group-executor] 6](("=S" "Sign using gpg" "--gpg-sign=" magit-read-gpg-secret-key))
  mapcar(#[(x) "\306�@\307\310#��A@��\205����!�\311\312 \n\f\203��\313\202 �\314\f\206%�\314%�\306
\315�@#,\207" [x head desc maker more text propertize face magit-key-mode-button-face format " %s: %s%s%s" " " "" key-group-executor] 6] (("=A" "Override the author" "--author=" read-from-minibuffer) ("=S" "Sign using gpg" "--gpg-sign=" magit-read-gpg-secret-key)))
  magit-key-mode-draw-buttons("Args" (("=A" "Override the author" "--author=" read-from-minibuffer) ("=S" "Sign using gpg" "--gpg-sign=" magit-read-gpg-secret-key)) #[(x) "\302\303\304�8\305\306\304�8    \307#\310\311##\207" [x magit-key-mode-current-args format "(%s) %s" 2 propertize gethash "" face magit-key-mode-args-face] 8] t)
  magit-key-mode-draw-args((("=A" "Override the author" "--author=" read-from-minibuffer) ("=S" "Sign using gpg" "--gpg-sign=" magit-read-gpg-secret-key)))
  magit-key-mode-draw(committing)
  magit-key-mode-redraw(committing)
  magit-key-mode-add-argument(committing "--gpg-sign=" magit-read-gpg-secret-key)
  (lambda nil (interactive) (magit-key-mode-add-argument (quote committing) "--gpg-sign=" (quote magit-read-gpg-secret-key)))()
  ad-Orig-call-interactively((lambda nil (interactive) (magit-key-mode-add-argument (quote committing) "--gpg-sign=" (quote magit-read-gpg-secret-key))) nil nil)
  call-interactively((lambda nil (interactive) (magit-key-mode-add-argument (quote committing) "--gpg-sign=" (quote magit-read-gpg-secret-key))) nil nil)

@tarsius
Copy link
Member

tarsius commented May 6, 2014

Try (setq magit-gpg-secret-key-hist nil) and then complete the key you want to use from scratch.

@tarsius
Copy link
Member

tarsius commented May 8, 2014

I had another look at the code and cannot see how this could possibly happen. (I did however notice that the history variable was not actually used as intended, which I fixed.)

Also I vaguely remember an issue similar to this one and that I then fixed. Are you sure you are using the Magit version you mentioned, maybe there is an old version laying around somewhere early on exec-path. Do M-x find-library RET magit RET, does that really open ~/.emacs.d/elpa/magit-20140505.301/magit.el?

Also try M-x eval-expression RET (magit-read-gpg-secret-key) RET. What does that print? Should be "sfsdfdsfdsfdsf" not "(sdfdsfdsfdsf superbil@example.com)".

@Superbil
Copy link
Author

Superbil commented May 9, 2014

@tarsius I checked it again, magit version is magit-20140505.301

and I eval (magit-read-gpg-secret-key) got error (toggle-debug-on-error)

Debugger entered--Lisp error: (wrong-number-of-arguments (lambda (prompt) (let ((keys (mapcar (function (lambda (key) (list (epg-sub-key-id (car (epg-key-sub-key-list key))) (let ((id-obj (car (epg-key-user-id-list key))) (id-str nil)) (if id-obj (progn (setq id-str (epg-user-id-string id-obj)) (if (stringp id-str) id-str (epg-decode-dn id-obj)))))))) (epg-list-keys (epg-make-context epa-protocol) nil t)))) (magit-completing-read prompt keys nil t nil nil (or (car magit-gpg-secret-key-hist) (car keys))))) 0)
  magit-read-gpg-secret-key()
  eval((magit-read-gpg-secret-key))
  pp-eval-expression((magit-read-gpg-secret-key))
  ad-Orig-call-interactively(pp-eval-expression nil nil)
  call-interactively(pp-eval-expression nil nil)

@tarsius
Copy link
Member

tarsius commented May 9, 2014

That indeed is the magit-read-gpg-secret-key from earlier this week. Unfortunately my instructions contained an error, you have to eval (magit-read-gpg-secret-key "prompt"). So this error is not the one we were trying to investigate. Sorry about that.

@tarsius
Copy link
Member

tarsius commented May 9, 2014

What version of Emacs are you using? Maybe the return value of one of the epg functions differs between versions.

@Superbil
Copy link
Author

@tarsius My Emacs version is GNU Emacs 24.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.36) of 2013-03-13 on bob.porkrind.org

when I eval (magit-read-gpg-secret-key "prompt"), I chose my key id then (I can't change to another), then it show ("Kai-Yuan Cheng (superbil) <superbil@gmail.com>") look normal.

@tarsius
Copy link
Member

tarsius commented May 14, 2014

Try (setq magit-gpg-secret-key-hist nil) and then complete the key you want to use from scratch.

Did you do that? Also don't forget to update Magit once more.

@Superbil
Copy link
Author

I use magit-20140514.730 try again, set (setq magit-gpg-secret-key-hist nil), I can't change to another key.
And I noticed eval (magit-read-gpg-secret-key) will got error.

Debugger entered--Lisp error: (wrong-number-of-arguments #[(prompt) "\304\305\306\307�!\310\311#\"\312
    \310\311\310\303�\206�� @&�)\207" [epa-protocol keys prompt magit-gpg-secret-key-hist mapcar #[(key) "\303\304�!@!\305�!@\306�\211�\205!�\307
!\211�;\203��   \202!�\310
!*D\207" [key id-str id-obj epg-sub-key-id epg-key-sub-key-list epg-key-user-id-list nil epg-user-id-string epg-decode-dn] 4] epg-list-keys epg-make-context nil t magit-completing-read] 8] 0)
  magit-read-gpg-secret-key()
  eval((magit-read-gpg-secret-key))
  pp-eval-expression((magit-read-gpg-secret-key))
  ad-Orig-call-interactively(pp-eval-expression nil nil)
  call-interactively(pp-eval-expression nil nil)

@tarsius
Copy link
Member

tarsius commented May 15, 2014

I can't change to another key.

Do you actually have another key?

And I noticed eval (magit-read-gpg-secret-key) will got error.

You forgot the mandatory PROMPT argument.

@Superbil
Copy link
Author

Yea, that is a sub key. I had try use git commit --gpg-sign=<SUB_KEY> to commit on it, it work just fine.

Oh, sorry about that I forgot the PROMPT argument, (magit-read-gpg-secret-key "prompt"), it work just fine.

I make a clean emacs.d, just install magit, sign using gpg was fine. And I noticed that it different at my origin.
At the clean one after I use =S to call sign, minibuffer will show --gpg-sign: (default (43A14F99206AFB69 Kai-Yuan Cheng (superbil) <superbil@gmail.com>)): but I use origin one, that is only show --gpg-sign: : [43A14F99206AFB69]. Both can't change to use with my sub key.

@tarsius
Copy link
Member

tarsius commented May 15, 2014

I have just pushed cdf7e11 to make it possible to enter a subkey. Subkeys are not offered for completion but once you have manually entered such a subkey, it is available from the history, so this shouldn't be to inconvenient.

@tarsius tarsius closed this as completed May 15, 2014
@tarsius tarsius modified the milestones: 2.1.0, support/later/needinfo/... May 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support User needs some help
Development

No branches or pull requests

3 participants